version 1.1, 2012/02/21 17:26:12
|
version 1.1.1.2, 2016/11/02 10:09:10
|
Line 41
|
Line 41
|
#include "ripd/ripd.h" |
#include "ripd/ripd.h" |
#include "ripd/rip_debug.h" |
#include "ripd/rip_debug.h" |
#include "ripd/rip_interface.h" |
#include "ripd/rip_interface.h" |
| |
/* static prototypes */ |
/* static prototypes */ |
static void rip_enable_apply (struct interface *); |
static void rip_enable_apply (struct interface *); |
static void rip_passive_interface_apply (struct interface *); |
static void rip_passive_interface_apply (struct interface *); |
Line 49 static int rip_if_down(struct interface *ifp);
|
Line 49 static int rip_if_down(struct interface *ifp);
|
static int rip_enable_if_lookup (const char *ifname); |
static int rip_enable_if_lookup (const char *ifname); |
static int rip_enable_network_lookup2 (struct connected *connected); |
static int rip_enable_network_lookup2 (struct connected *connected); |
static void rip_enable_apply_all (void); |
static void rip_enable_apply_all (void); |
| |
struct message ri_version_msg[] = | const struct message ri_version_msg[] = |
{ |
{ |
{RI_RIP_VERSION_1, "1"}, |
{RI_RIP_VERSION_1, "1"}, |
{RI_RIP_VERSION_2, "2"}, |
{RI_RIP_VERSION_2, "2"}, |
Line 68 struct route_table *rip_enable_network;
|
Line 68 struct route_table *rip_enable_network;
|
/* Vector to store passive-interface name. */ |
/* Vector to store passive-interface name. */ |
static int passive_default; /* are we in passive-interface default mode? */ |
static int passive_default; /* are we in passive-interface default mode? */ |
vector Vrip_passive_nondefault; |
vector Vrip_passive_nondefault; |
| |
/* Join to the RIP version 2 multicast group. */ |
/* Join to the RIP version 2 multicast group. */ |
static int |
static int |
ipv4_multicast_join (int sock, |
ipv4_multicast_join (int sock, |
struct in_addr group, |
struct in_addr group, |
struct in_addr ifa, |
struct in_addr ifa, |
unsigned int ifindex) | ifindex_t ifindex) |
{ |
{ |
int ret; |
int ret; |
|
|
Line 95 static int
|
Line 95 static int
|
ipv4_multicast_leave (int sock, |
ipv4_multicast_leave (int sock, |
struct in_addr group, |
struct in_addr group, |
struct in_addr ifa, |
struct in_addr ifa, |
unsigned int ifindex) | ifindex_t ifindex) |
{ |
{ |
int ret; |
int ret; |
|
|
Line 109 ipv4_multicast_leave (int sock,
|
Line 109 ipv4_multicast_leave (int sock,
|
|
|
return ret; |
return ret; |
} |
} |
| |
/* Allocate new RIP's interface configuration. */ |
/* Allocate new RIP's interface configuration. */ |
static struct rip_interface * |
static struct rip_interface * |
rip_interface_new (void) |
rip_interface_new (void) |
Line 380 if_check_address (struct in_addr addr)
|
Line 380 if_check_address (struct in_addr addr)
|
|
|
/* Inteface link down message processing. */ |
/* Inteface link down message processing. */ |
int |
int |
rip_interface_down (int command, struct zclient *zclient, zebra_size_t length) | rip_interface_down (int command, struct zclient *zclient, zebra_size_t length, |
| vrf_id_t vrf_id) |
{ |
{ |
struct interface *ifp; |
struct interface *ifp; |
struct stream *s; |
struct stream *s; |
Line 389 rip_interface_down (int command, struct zclient *zclie
|
Line 390 rip_interface_down (int command, struct zclient *zclie
|
|
|
/* zebra_interface_state_read() updates interface structure in |
/* zebra_interface_state_read() updates interface structure in |
iflist. */ |
iflist. */ |
ifp = zebra_interface_state_read(s); | ifp = zebra_interface_state_read (s, vrf_id); |
|
|
if (ifp == NULL) |
if (ifp == NULL) |
return 0; |
return 0; |
Line 406 rip_interface_down (int command, struct zclient *zclie
|
Line 407 rip_interface_down (int command, struct zclient *zclie
|
|
|
/* Inteface link up message processing */ |
/* Inteface link up message processing */ |
int |
int |
rip_interface_up (int command, struct zclient *zclient, zebra_size_t length) | rip_interface_up (int command, struct zclient *zclient, zebra_size_t length, |
| vrf_id_t vrf_id) |
{ |
{ |
struct interface *ifp; |
struct interface *ifp; |
|
|
/* zebra_interface_state_read () updates interface structure in |
/* zebra_interface_state_read () updates interface structure in |
iflist. */ |
iflist. */ |
ifp = zebra_interface_state_read (zclient->ibuf); | ifp = zebra_interface_state_read (zclient->ibuf, vrf_id); |
|
|
if (ifp == NULL) |
if (ifp == NULL) |
return 0; |
return 0; |
Line 436 rip_interface_up (int command, struct zclient *zclient
|
Line 438 rip_interface_up (int command, struct zclient *zclient
|
|
|
/* Inteface addition message from zebra. */ |
/* Inteface addition message from zebra. */ |
int |
int |
rip_interface_add (int command, struct zclient *zclient, zebra_size_t length) | rip_interface_add (int command, struct zclient *zclient, zebra_size_t length, |
| vrf_id_t vrf_id) |
{ |
{ |
struct interface *ifp; |
struct interface *ifp; |
|
|
ifp = zebra_interface_add_read (zclient->ibuf); | ifp = zebra_interface_add_read (zclient->ibuf, vrf_id); |
|
|
if (IS_RIP_DEBUG_ZEBRA) |
if (IS_RIP_DEBUG_ZEBRA) |
zlog_debug ("interface add %s index %d flags %#llx metric %d mtu %d", |
zlog_debug ("interface add %s index %d flags %#llx metric %d mtu %d", |
Line 466 rip_interface_add (int command, struct zclient *zclien
|
Line 469 rip_interface_add (int command, struct zclient *zclien
|
|
|
int |
int |
rip_interface_delete (int command, struct zclient *zclient, |
rip_interface_delete (int command, struct zclient *zclient, |
zebra_size_t length) | zebra_size_t length, vrf_id_t vrf_id) |
{ |
{ |
struct interface *ifp; |
struct interface *ifp; |
struct stream *s; |
struct stream *s; |
Line 474 rip_interface_delete (int command, struct zclient *zcl
|
Line 477 rip_interface_delete (int command, struct zclient *zcl
|
|
|
s = zclient->ibuf; |
s = zclient->ibuf; |
/* zebra_interface_state_read() updates interface structure in iflist */ |
/* zebra_interface_state_read() updates interface structure in iflist */ |
ifp = zebra_interface_state_read(s); | ifp = zebra_interface_state_read (s, vrf_id); |
|
|
if (ifp == NULL) |
if (ifp == NULL) |
return 0; |
return 0; |
Line 577 rip_if_down(struct interface *ifp)
|
Line 580 rip_if_down(struct interface *ifp)
|
struct route_node *rp; |
struct route_node *rp; |
struct rip_info *rinfo; |
struct rip_info *rinfo; |
struct rip_interface *ri = NULL; |
struct rip_interface *ri = NULL; |
|
struct list *list = NULL; |
|
struct listnode *listnode = NULL, *nextnode = NULL; |
if (rip) |
if (rip) |
{ | for (rp = route_top (rip->table); rp; rp = route_next (rp)) |
for (rp = route_top (rip->table); rp; rp = route_next (rp)) | if ((list = rp->info) != NULL) |
if ((rinfo = rp->info) != NULL) | for (ALL_LIST_ELEMENTS (list, listnode, nextnode, rinfo)) |
{ | if (rinfo->ifindex == ifp->ifindex) |
/* Routes got through this interface. */ | rip_ecmp_delete (rinfo); |
if (rinfo->ifindex == ifp->ifindex && | |
rinfo->type == ZEBRA_ROUTE_RIP && | |
rinfo->sub_type == RIP_ROUTE_RTE) | |
{ | |
rip_zebra_ipv4_delete ((struct prefix_ipv4 *) &rp->p, | |
&rinfo->nexthop, | |
rinfo->metric); | |
|
|
rip_redistribute_delete (rinfo->type,rinfo->sub_type, |
|
(struct prefix_ipv4 *)&rp->p, |
|
rinfo->ifindex); |
|
} |
|
else |
|
{ |
|
/* All redistributed routes but static and system */ |
|
if ((rinfo->ifindex == ifp->ifindex) && |
|
/* (rinfo->type != ZEBRA_ROUTE_STATIC) && */ |
|
(rinfo->type != ZEBRA_ROUTE_SYSTEM)) |
|
rip_redistribute_delete (rinfo->type,rinfo->sub_type, |
|
(struct prefix_ipv4 *)&rp->p, |
|
rinfo->ifindex); |
|
} |
|
} |
|
} |
|
|
|
ri = ifp->info; |
ri = ifp->info; |
|
|
if (ri->running) |
if (ri->running) |
Line 666 rip_apply_address_add (struct connected *ifc)
|
Line 647 rip_apply_address_add (struct connected *ifc)
|
|
|
int |
int |
rip_interface_address_add (int command, struct zclient *zclient, |
rip_interface_address_add (int command, struct zclient *zclient, |
zebra_size_t length) | zebra_size_t length, vrf_id_t vrf_id) |
{ |
{ |
struct connected *ifc; |
struct connected *ifc; |
struct prefix *p; |
struct prefix *p; |
|
|
ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, |
ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, |
zclient->ibuf); | zclient->ibuf, vrf_id); |
|
|
if (ifc == NULL) |
if (ifc == NULL) |
return 0; |
return 0; |
Line 722 rip_apply_address_del (struct connected *ifc) {
|
Line 703 rip_apply_address_del (struct connected *ifc) {
|
|
|
int |
int |
rip_interface_address_delete (int command, struct zclient *zclient, |
rip_interface_address_delete (int command, struct zclient *zclient, |
zebra_size_t length) | zebra_size_t length, vrf_id_t vrf_id) |
{ |
{ |
struct connected *ifc; |
struct connected *ifc; |
struct prefix *p; |
struct prefix *p; |
|
|
ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, |
ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, |
zclient->ibuf); | zclient->ibuf, vrf_id); |
|
|
if (ifc) |
if (ifc) |
{ |
{ |
Line 754 rip_interface_address_delete (int command, struct zcli
|
Line 735 rip_interface_address_delete (int command, struct zcli
|
|
|
return 0; |
return 0; |
} |
} |
| |
/* Check interface is enabled by network statement. */ |
/* Check interface is enabled by network statement. */ |
/* Check wether the interface has at least a connected prefix that |
/* Check wether the interface has at least a connected prefix that |
* is within the ripng_enable_network table. */ |
* is within the ripng_enable_network table. */ |
Line 1142 rip_clean_network ()
|
Line 1123 rip_clean_network ()
|
vector_slot (rip_enable_interface, i) = NULL; |
vector_slot (rip_enable_interface, i) = NULL; |
} |
} |
} |
} |
| |
/* Utility function for looking up passive interface settings. */ |
/* Utility function for looking up passive interface settings. */ |
static int |
static int |
rip_passive_nondefault_lookup (const char *ifname) |
rip_passive_nondefault_lookup (const char *ifname) |
Line 1229 rip_passive_nondefault_clean (void)
|
Line 1210 rip_passive_nondefault_clean (void)
|
} |
} |
rip_passive_interface_apply_all (); |
rip_passive_interface_apply_all (); |
} |
} |
| |
/* RIP enable network or interface configuration. */ |
/* RIP enable network or interface configuration. */ |
DEFUN (rip_network, |
DEFUN (rip_network, |
rip_network_cmd, |
rip_network_cmd, |
Line 1913 DEFUN (no_rip_passive_interface,
|
Line 1894 DEFUN (no_rip_passive_interface,
|
else |
else |
return rip_passive_nondefault_unset (vty, ifname); |
return rip_passive_nondefault_unset (vty, ifname); |
} |
} |
| |
/* Write rip configuration of each interface. */ |
/* Write rip configuration of each interface. */ |
static int |
static int |
rip_interface_config_write (struct vty *vty) |
rip_interface_config_write (struct vty *vty) |
Line 2077 void
|
Line 2058 void
|
rip_if_init (void) |
rip_if_init (void) |
{ |
{ |
/* Default initial size of interface vector. */ |
/* Default initial size of interface vector. */ |
if_init(); |
|
if_add_hook (IF_NEW_HOOK, rip_interface_new_hook); |
if_add_hook (IF_NEW_HOOK, rip_interface_new_hook); |
if_add_hook (IF_DELETE_HOOK, rip_interface_delete_hook); |
if_add_hook (IF_DELETE_HOOK, rip_interface_delete_hook); |
|
|