mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-16 13:41:46 +00:00
zebra: start detangling rtadv & irdp
Replace some cross-dependencies with hooks & move bits to where they belong. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
ce19a04aea
commit
2eb27eecf0
@ -52,11 +52,10 @@
|
|||||||
|
|
||||||
#define ZEBRA_PTM_SUPPORT
|
#define ZEBRA_PTM_SUPPORT
|
||||||
|
|
||||||
#if defined(HAVE_RTADV)
|
DEFINE_HOOK(zebra_if_extra_info, (struct vty *vty, struct interface *ifp),
|
||||||
/* Order is intentional. Matches RFC4191. This array is also used for
|
(vty, ifp))
|
||||||
command matching, so only modify with care. */
|
DEFINE_HOOK(zebra_if_config_wr, (struct vty *vty, struct interface *ifp),
|
||||||
const char *rtadv_pref_strs[] = {"medium", "high", "INVALID", "low", 0};
|
(vty, ifp))
|
||||||
#endif /* HAVE_RTADV */
|
|
||||||
|
|
||||||
static void if_down_del_nbr_connected(struct interface *ifp);
|
static void if_down_del_nbr_connected(struct interface *ifp);
|
||||||
|
|
||||||
@ -996,74 +995,6 @@ static void nbr_connected_dump_vty(struct vty *vty,
|
|||||||
vty_out(vty, "\n");
|
vty_out(vty, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_RTADV)
|
|
||||||
/* Dump interface ND information to vty. */
|
|
||||||
static void nd_dump_vty(struct vty *vty, struct interface *ifp)
|
|
||||||
{
|
|
||||||
struct zebra_if *zif;
|
|
||||||
struct rtadvconf *rtadv;
|
|
||||||
int interval;
|
|
||||||
|
|
||||||
zif = (struct zebra_if *)ifp->info;
|
|
||||||
rtadv = &zif->rtadv;
|
|
||||||
|
|
||||||
if (rtadv->AdvSendAdvertisements) {
|
|
||||||
vty_out(vty,
|
|
||||||
" ND advertised reachable time is %d milliseconds\n",
|
|
||||||
rtadv->AdvReachableTime);
|
|
||||||
vty_out(vty,
|
|
||||||
" ND advertised retransmit interval is %d milliseconds\n",
|
|
||||||
rtadv->AdvRetransTimer);
|
|
||||||
vty_out(vty, " ND router advertisements sent: %d rcvd: %d\n",
|
|
||||||
zif->ra_sent, zif->ra_rcvd);
|
|
||||||
interval = rtadv->MaxRtrAdvInterval;
|
|
||||||
if (interval % 1000)
|
|
||||||
vty_out(vty,
|
|
||||||
" ND router advertisements are sent every "
|
|
||||||
"%d milliseconds\n",
|
|
||||||
interval);
|
|
||||||
else
|
|
||||||
vty_out(vty,
|
|
||||||
" ND router advertisements are sent every "
|
|
||||||
"%d seconds\n",
|
|
||||||
interval / 1000);
|
|
||||||
if (rtadv->AdvDefaultLifetime != -1)
|
|
||||||
vty_out(vty,
|
|
||||||
" ND router advertisements live for %d seconds\n",
|
|
||||||
rtadv->AdvDefaultLifetime);
|
|
||||||
else
|
|
||||||
vty_out(vty,
|
|
||||||
" ND router advertisements lifetime tracks ra-interval\n");
|
|
||||||
vty_out(vty,
|
|
||||||
" ND router advertisement default router preference is "
|
|
||||||
"%s\n",
|
|
||||||
rtadv_pref_strs[rtadv->DefaultPreference]);
|
|
||||||
if (rtadv->AdvManagedFlag)
|
|
||||||
vty_out(vty,
|
|
||||||
" Hosts use DHCP to obtain routable addresses.\n");
|
|
||||||
else
|
|
||||||
vty_out(vty,
|
|
||||||
" Hosts use stateless autoconfig for addresses.\n");
|
|
||||||
if (rtadv->AdvHomeAgentFlag) {
|
|
||||||
vty_out(vty,
|
|
||||||
" ND router advertisements with Home Agent flag bit set.\n");
|
|
||||||
if (rtadv->HomeAgentLifetime != -1)
|
|
||||||
vty_out(vty,
|
|
||||||
" Home Agent lifetime is %u seconds\n",
|
|
||||||
rtadv->HomeAgentLifetime);
|
|
||||||
else
|
|
||||||
vty_out(vty,
|
|
||||||
" Home Agent lifetime tracks ra-lifetime\n");
|
|
||||||
vty_out(vty, " Home Agent preference is %u\n",
|
|
||||||
rtadv->HomeAgentPreference);
|
|
||||||
}
|
|
||||||
if (rtadv->AdvIntervalOption)
|
|
||||||
vty_out(vty,
|
|
||||||
" ND router advertisements with Adv. Interval option.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* HAVE_RTADV */
|
|
||||||
|
|
||||||
static const char *zebra_ziftype_2str(zebra_iftype_t zif_type)
|
static const char *zebra_ziftype_2str(zebra_iftype_t zif_type)
|
||||||
{
|
{
|
||||||
switch (zif_type) {
|
switch (zif_type) {
|
||||||
@ -1277,12 +1208,8 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp)
|
|||||||
inet_ntoa(iflp->rmt_ip), iflp->rmt_as);
|
inet_ntoa(iflp->rmt_ip), iflp->rmt_as);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RTADV
|
hook_call(zebra_if_extra_info, vty, ifp);
|
||||||
nd_dump_vty(vty, ifp);
|
|
||||||
#endif /* RTADV */
|
|
||||||
#if defined(HAVE_RTADV)
|
|
||||||
nd_dump_vty(vty, ifp);
|
|
||||||
#endif /* HAVE_RTADV */
|
|
||||||
if (listhead(ifp->nbr_connected))
|
if (listhead(ifp->nbr_connected))
|
||||||
vty_out(vty, " Neighbor address(s):\n");
|
vty_out(vty, " Neighbor address(s):\n");
|
||||||
for (ALL_LIST_ELEMENTS_RO(ifp->nbr_connected, node, nbr_connected))
|
for (ALL_LIST_ELEMENTS_RO(ifp->nbr_connected, node, nbr_connected))
|
||||||
@ -2911,13 +2838,7 @@ static int if_config_write(struct vty *vty)
|
|||||||
: "no ");
|
: "no ");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_RTADV)
|
hook_call(zebra_if_config_wr, vty, ifp);
|
||||||
rtadv_config_write(vty, ifp);
|
|
||||||
#endif /* HAVE_RTADV */
|
|
||||||
|
|
||||||
#ifdef HAVE_IRDP
|
|
||||||
irdp_config_write(vty, ifp);
|
|
||||||
#endif /* IRDP */
|
|
||||||
|
|
||||||
link_params_config_write(vty, ifp);
|
link_params_config_write(vty, ifp);
|
||||||
|
|
||||||
|
@ -23,10 +23,7 @@
|
|||||||
|
|
||||||
#include "redistribute.h"
|
#include "redistribute.h"
|
||||||
#include "vrf.h"
|
#include "vrf.h"
|
||||||
|
#include "hook.h"
|
||||||
#ifdef HAVE_IRDP
|
|
||||||
#include "zebra/irdp.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "zebra/zebra_l2.h"
|
#include "zebra/zebra_l2.h"
|
||||||
|
|
||||||
@ -202,6 +199,8 @@ typedef enum {
|
|||||||
ZEBRA_IF_SLAVE_OTHER, /* Something else - e.g., bond slave */
|
ZEBRA_IF_SLAVE_OTHER, /* Something else - e.g., bond slave */
|
||||||
} zebra_slave_iftype_t;
|
} zebra_slave_iftype_t;
|
||||||
|
|
||||||
|
struct irdp_interface;
|
||||||
|
|
||||||
/* `zebra' daemon local interface structure. */
|
/* `zebra' daemon local interface structure. */
|
||||||
struct zebra_if {
|
struct zebra_if {
|
||||||
/* Shutdown configuration. */
|
/* Shutdown configuration. */
|
||||||
@ -227,9 +226,7 @@ struct zebra_if {
|
|||||||
unsigned int ra_sent, ra_rcvd;
|
unsigned int ra_sent, ra_rcvd;
|
||||||
#endif /* HAVE_RTADV */
|
#endif /* HAVE_RTADV */
|
||||||
|
|
||||||
#ifdef HAVE_IRDP
|
struct irdp_interface *irdp;
|
||||||
struct irdp_interface irdp;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_STRUCT_SOCKADDR_DL
|
#ifdef HAVE_STRUCT_SOCKADDR_DL
|
||||||
union {
|
union {
|
||||||
@ -273,6 +270,11 @@ struct zebra_if {
|
|||||||
struct interface *link;
|
struct interface *link;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DECLARE_HOOK(zebra_if_extra_info, (struct vty *vty, struct interface *ifp),
|
||||||
|
(vty, ifp))
|
||||||
|
DECLARE_HOOK(zebra_if_config_wr, (struct vty *vty, struct interface *ifp),
|
||||||
|
(vty, ifp))
|
||||||
|
|
||||||
static inline void zebra_if_set_ziftype(struct interface *ifp,
|
static inline void zebra_if_set_ziftype(struct interface *ifp,
|
||||||
zebra_iftype_t zif_type,
|
zebra_iftype_t zif_type,
|
||||||
zebra_slave_iftype_t zif_slave_type)
|
zebra_slave_iftype_t zif_slave_type)
|
||||||
|
@ -139,9 +139,9 @@ struct Adv {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern void irdp_init(void);
|
extern void irdp_init(void);
|
||||||
|
extern void irdp_if_init(void);
|
||||||
extern int irdp_sock_init(void);
|
extern int irdp_sock_init(void);
|
||||||
extern void irdp_finish(void);
|
extern int irdp_config_write(struct vty *, struct interface *);
|
||||||
extern void irdp_config_write(struct vty *, struct interface *);
|
|
||||||
extern int irdp_send_thread(struct thread *t_advert);
|
extern int irdp_send_thread(struct thread *t_advert);
|
||||||
extern void irdp_advert_off(struct interface *ifp);
|
extern void irdp_advert_off(struct interface *ifp);
|
||||||
extern void process_solicit(struct interface *ifp);
|
extern void process_solicit(struct interface *ifp);
|
||||||
|
@ -316,7 +316,7 @@ static void irdp_if_no_shutdown(struct interface *ifp)
|
|||||||
|
|
||||||
/* Write configuration to user */
|
/* Write configuration to user */
|
||||||
|
|
||||||
void irdp_config_write(struct vty *vty, struct interface *ifp)
|
int irdp_config_write(struct vty *vty, struct interface *ifp)
|
||||||
{
|
{
|
||||||
struct zebra_if *zi = ifp->info;
|
struct zebra_if *zi = ifp->info;
|
||||||
struct irdp_interface *irdp = &zi->irdp;
|
struct irdp_interface *irdp = &zi->irdp;
|
||||||
@ -348,6 +348,7 @@ void irdp_config_write(struct vty *vty, struct interface *ifp)
|
|||||||
vty_out(vty, " ip irdp maxadvertinterval %ld\n",
|
vty_out(vty, " ip irdp maxadvertinterval %ld\n",
|
||||||
irdp->MaxAdvertInterval);
|
irdp->MaxAdvertInterval);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -678,8 +679,10 @@ DEFUN (ip_irdp_debug_disable,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void irdp_init()
|
void irdp_if_init()
|
||||||
{
|
{
|
||||||
|
hook_register(zebra_if_config_wr, irdp_config_write);
|
||||||
|
|
||||||
install_element(INTERFACE_NODE, &ip_irdp_broadcast_cmd);
|
install_element(INTERFACE_NODE, &ip_irdp_broadcast_cmd);
|
||||||
install_element(INTERFACE_NODE, &ip_irdp_multicast_cmd);
|
install_element(INTERFACE_NODE, &ip_irdp_multicast_cmd);
|
||||||
install_element(INTERFACE_NODE, &no_ip_irdp_cmd);
|
install_element(INTERFACE_NODE, &no_ip_irdp_cmd);
|
||||||
|
@ -301,7 +301,7 @@ void process_solicit(struct interface *ifp)
|
|||||||
&irdp->t_advertise);
|
&irdp->t_advertise);
|
||||||
}
|
}
|
||||||
|
|
||||||
void irdp_finish()
|
static int irdp_finish(void)
|
||||||
{
|
{
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
struct listnode *node, *nnode;
|
struct listnode *node, *nnode;
|
||||||
@ -328,4 +328,11 @@ void irdp_finish()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void irdp_init(void)
|
||||||
|
{
|
||||||
|
irdp_if_init();
|
||||||
|
|
||||||
|
hook_register(frr_early_fini, irdp_finish);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* HAVE_IRDP */
|
#endif /* HAVE_IRDP */
|
||||||
|
@ -126,9 +126,6 @@ static void sigint(void)
|
|||||||
zlog_notice("Terminating on signal");
|
zlog_notice("Terminating on signal");
|
||||||
|
|
||||||
frr_early_fini();
|
frr_early_fini();
|
||||||
#ifdef HAVE_IRDP
|
|
||||||
irdp_finish();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
zebra_ptm_finish();
|
zebra_ptm_finish();
|
||||||
list_delete_all_node(zebrad.client_list);
|
list_delete_all_node(zebrad.client_list);
|
||||||
|
@ -62,6 +62,10 @@ extern struct zebra_privs_t zserv_privs;
|
|||||||
#define ALLNODE "ff02::1"
|
#define ALLNODE "ff02::1"
|
||||||
#define ALLROUTER "ff02::2"
|
#define ALLROUTER "ff02::2"
|
||||||
|
|
||||||
|
/* Order is intentional. Matches RFC4191. This array is also used for
|
||||||
|
command matching, so only modify with care. */
|
||||||
|
const char *rtadv_pref_strs[] = {"medium", "high", "INVALID", "low", 0};
|
||||||
|
|
||||||
enum rtadv_event {
|
enum rtadv_event {
|
||||||
RTADV_START,
|
RTADV_START,
|
||||||
RTADV_STOP,
|
RTADV_STOP,
|
||||||
@ -1456,9 +1460,76 @@ DEFUN (no_ipv6_nd_mtu,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Dump interface ND information to vty. */
|
||||||
|
static int nd_dump_vty(struct vty *vty, struct interface *ifp)
|
||||||
|
{
|
||||||
|
struct zebra_if *zif;
|
||||||
|
struct rtadvconf *rtadv;
|
||||||
|
int interval;
|
||||||
|
|
||||||
|
zif = (struct zebra_if *)ifp->info;
|
||||||
|
rtadv = &zif->rtadv;
|
||||||
|
|
||||||
|
if (rtadv->AdvSendAdvertisements) {
|
||||||
|
vty_out(vty,
|
||||||
|
" ND advertised reachable time is %d milliseconds\n",
|
||||||
|
rtadv->AdvReachableTime);
|
||||||
|
vty_out(vty,
|
||||||
|
" ND advertised retransmit interval is %d milliseconds\n",
|
||||||
|
rtadv->AdvRetransTimer);
|
||||||
|
vty_out(vty, " ND router advertisements sent: %d rcvd: %d\n",
|
||||||
|
zif->ra_sent, zif->ra_rcvd);
|
||||||
|
interval = rtadv->MaxRtrAdvInterval;
|
||||||
|
if (interval % 1000)
|
||||||
|
vty_out(vty,
|
||||||
|
" ND router advertisements are sent every "
|
||||||
|
"%d milliseconds\n",
|
||||||
|
interval);
|
||||||
|
else
|
||||||
|
vty_out(vty,
|
||||||
|
" ND router advertisements are sent every "
|
||||||
|
"%d seconds\n",
|
||||||
|
interval / 1000);
|
||||||
|
if (rtadv->AdvDefaultLifetime != -1)
|
||||||
|
vty_out(vty,
|
||||||
|
" ND router advertisements live for %d seconds\n",
|
||||||
|
rtadv->AdvDefaultLifetime);
|
||||||
|
else
|
||||||
|
vty_out(vty,
|
||||||
|
" ND router advertisements lifetime tracks ra-interval\n");
|
||||||
|
vty_out(vty,
|
||||||
|
" ND router advertisement default router preference is "
|
||||||
|
"%s\n",
|
||||||
|
rtadv_pref_strs[rtadv->DefaultPreference]);
|
||||||
|
if (rtadv->AdvManagedFlag)
|
||||||
|
vty_out(vty,
|
||||||
|
" Hosts use DHCP to obtain routable addresses.\n");
|
||||||
|
else
|
||||||
|
vty_out(vty,
|
||||||
|
" Hosts use stateless autoconfig for addresses.\n");
|
||||||
|
if (rtadv->AdvHomeAgentFlag) {
|
||||||
|
vty_out(vty,
|
||||||
|
" ND router advertisements with Home Agent flag bit set.\n");
|
||||||
|
if (rtadv->HomeAgentLifetime != -1)
|
||||||
|
vty_out(vty,
|
||||||
|
" Home Agent lifetime is %u seconds\n",
|
||||||
|
rtadv->HomeAgentLifetime);
|
||||||
|
else
|
||||||
|
vty_out(vty,
|
||||||
|
" Home Agent lifetime tracks ra-lifetime\n");
|
||||||
|
vty_out(vty, " Home Agent preference is %u\n",
|
||||||
|
rtadv->HomeAgentPreference);
|
||||||
|
}
|
||||||
|
if (rtadv->AdvIntervalOption)
|
||||||
|
vty_out(vty,
|
||||||
|
" ND router advertisements with Adv. Interval option.\n");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Write configuration about router advertisement. */
|
/* Write configuration about router advertisement. */
|
||||||
void rtadv_config_write(struct vty *vty, struct interface *ifp)
|
static int rtadv_config_write(struct vty *vty, struct interface *ifp)
|
||||||
{
|
{
|
||||||
struct zebra_if *zif;
|
struct zebra_if *zif;
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
@ -1539,6 +1610,7 @@ void rtadv_config_write(struct vty *vty, struct interface *ifp)
|
|||||||
vty_out(vty, " router-address");
|
vty_out(vty, " router-address");
|
||||||
vty_out(vty, "\n");
|
vty_out(vty, "\n");
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1600,6 +1672,9 @@ void rtadv_terminate(struct zebra_ns *zns)
|
|||||||
|
|
||||||
void rtadv_cmd_init(void)
|
void rtadv_cmd_init(void)
|
||||||
{
|
{
|
||||||
|
hook_register(zebra_if_extra_info, nd_dump_vty);
|
||||||
|
hook_register(zebra_if_config_wr, rtadv_config_write);
|
||||||
|
|
||||||
install_element(INTERFACE_NODE, &ipv6_nd_suppress_ra_cmd);
|
install_element(INTERFACE_NODE, &ipv6_nd_suppress_ra_cmd);
|
||||||
install_element(INTERFACE_NODE, &no_ipv6_nd_suppress_ra_cmd);
|
install_element(INTERFACE_NODE, &no_ipv6_nd_suppress_ra_cmd);
|
||||||
install_element(INTERFACE_NODE, &ipv6_nd_ra_interval_cmd);
|
install_element(INTERFACE_NODE, &ipv6_nd_ra_interval_cmd);
|
||||||
|
@ -55,8 +55,6 @@ struct rtadv_prefix {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void rtadv_config_write(struct vty *, struct interface *);
|
|
||||||
|
|
||||||
/* RFC4584 Extension to Sockets API for Mobile IPv6 */
|
/* RFC4584 Extension to Sockets API for Mobile IPv6 */
|
||||||
|
|
||||||
#ifndef ND_OPT_ADV_INTERVAL
|
#ifndef ND_OPT_ADV_INTERVAL
|
||||||
|
Loading…
Reference in New Issue
Block a user