diff options
Diffstat (limited to 'ospfd/ospf_zebra.c')
-rw-r--r-- | ospfd/ospf_zebra.c | 81 |
1 files changed, 54 insertions, 27 deletions
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index a95b2e1b6..15585eaea 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -62,7 +62,7 @@ struct in_addr router_id_zebra; /* Router-id update message from zebra. */ static int ospf_router_id_update_zebra (int command, struct zclient *zclient, - zebra_size_t length) + zebra_size_t length, vrf_id_t vrf_id) { struct ospf *ospf; struct prefix router_id; @@ -87,11 +87,12 @@ ospf_router_id_update_zebra (int command, struct zclient *zclient, /* Inteface addition message from zebra. */ static int -ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length) +ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length, + vrf_id_t vrf_id) { struct interface *ifp; - ifp = zebra_interface_add_read (zclient->ibuf); + ifp = zebra_interface_add_read (zclient->ibuf, vrf_id); if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) zlog_debug ("Zebra: interface add %s index %d flags %llx metric %d mtu %d", @@ -117,7 +118,7 @@ ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length) static int ospf_interface_delete (int command, struct zclient *zclient, - zebra_size_t length) + zebra_size_t length, vrf_id_t vrf_id) { struct interface *ifp; struct stream *s; @@ -125,7 +126,7 @@ ospf_interface_delete (int command, struct zclient *zclient, s = zclient->ibuf; /* 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) return 0; @@ -152,7 +153,7 @@ ospf_interface_delete (int command, struct zclient *zclient, } static struct interface * -zebra_interface_if_lookup (struct stream *s) +zebra_interface_if_lookup (struct stream *s, vrf_id_t vrf_id) { char ifname_tmp[INTERFACE_NAMSIZ]; @@ -166,13 +167,13 @@ zebra_interface_if_lookup (struct stream *s) static int ospf_interface_state_up (int command, struct zclient *zclient, - zebra_size_t length) + zebra_size_t length, vrf_id_t vrf_id) { struct interface *ifp; struct ospf_interface *oi; struct route_node *rn; - ifp = zebra_interface_if_lookup (zclient->ibuf); + ifp = zebra_interface_if_lookup (zclient->ibuf, vrf_id); if (ifp == NULL) return 0; @@ -228,13 +229,13 @@ ospf_interface_state_up (int command, struct zclient *zclient, static int ospf_interface_state_down (int command, struct zclient *zclient, - zebra_size_t length) + zebra_size_t length, vrf_id_t vrf_id) { struct interface *ifp; struct ospf_interface *oi; struct route_node *node; - ifp = zebra_interface_state_read (zclient->ibuf); + ifp = zebra_interface_state_read (zclient->ibuf, vrf_id); if (ifp == NULL) return 0; @@ -254,11 +255,11 @@ ospf_interface_state_down (int command, struct zclient *zclient, static int ospf_interface_address_add (int command, struct zclient *zclient, - zebra_size_t length) + zebra_size_t length, vrf_id_t vrf_id) { struct connected *c; - c = zebra_interface_address_read (command, zclient->ibuf); + c = zebra_interface_address_read (command, zclient->ibuf, vrf_id); if (c == NULL) return 0; @@ -281,7 +282,7 @@ ospf_interface_address_add (int command, struct zclient *zclient, static int ospf_interface_address_delete (int command, struct zclient *zclient, - zebra_size_t length) + zebra_size_t length, vrf_id_t vrf_id) { struct connected *c; struct interface *ifp; @@ -289,7 +290,7 @@ ospf_interface_address_delete (int command, struct zclient *zclient, struct route_node *rn; struct prefix p; - c = zebra_interface_address_read (command, zclient->ibuf); + c = zebra_interface_address_read (command, zclient->ibuf, vrf_id); if (c == NULL) return 0; @@ -339,7 +340,10 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or) struct listnode *node; struct ospf *ospf = ospf_lookup (); - if (redist_check_instance(&zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF], ospf->instance)) + if ((ospf->instance && + redist_check_instance(&zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF], ospf->instance)) + || + vrf_bitmap_check (zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF], VRF_DEFAULT)) { message = 0; flags = 0; @@ -364,7 +368,7 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or) stream_reset (s); /* Put command, type, flags, message. */ - zclient_create_header (s, ZEBRA_IPV4_ROUTE_ADD); + zclient_create_header (s, ZEBRA_IPV4_ROUTE_ADD, VRF_DEFAULT); stream_putc (s, ZEBRA_ROUTE_OSPF); stream_putw (s, ospf->instance); stream_putc (s, flags); @@ -484,7 +488,10 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or) struct listnode *node; struct ospf *ospf = ospf_lookup (); - if (redist_check_instance(&zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF], ospf->instance)) + if ((ospf->instance && + redist_check_instance(&zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF], ospf->instance)) + || + vrf_bitmap_check (zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF], VRF_DEFAULT)) { message = 0; flags = 0; @@ -495,7 +502,7 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or) stream_reset (s); /* Put command, type, flags, message. */ - zclient_create_header (s, ZEBRA_IPV4_ROUTE_DELETE); + zclient_create_header (s, ZEBRA_IPV4_ROUTE_DELETE, VRF_DEFAULT); stream_putc (s, ZEBRA_ROUTE_OSPF); stream_putw (s, ospf->instance); stream_putc (s, flags); @@ -567,8 +574,12 @@ ospf_zebra_add_discard (struct prefix_ipv4 *p) struct zapi_ipv4 api; struct ospf *ospf = ospf_lookup (); - if (redist_check_instance(&zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF], ospf->instance)) + if ((ospf->instance && + redist_check_instance(&zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF], ospf->instance)) + || + vrf_bitmap_check (zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF], VRF_DEFAULT)) { + api.vrf_id = VRF_DEFAULT; api.type = ZEBRA_ROUTE_OSPF; api.instance = ospf->instance; api.flags = ZEBRA_FLAG_BLACKHOLE; @@ -593,8 +604,12 @@ ospf_zebra_delete_discard (struct prefix_ipv4 *p) struct zapi_ipv4 api; struct ospf *ospf = ospf_lookup (); - if (redist_check_instance(&zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF], ospf->instance)) + if ((ospf->instance && + redist_check_instance(&zclient->mi_redist[AFI_IP][ZEBRA_ROUTE_OSPF], ospf->instance)) + || + vrf_bitmap_check (zclient->redist[AFI_IP][ZEBRA_ROUTE_OSPF], VRF_DEFAULT)) { + api.vrf_id = VRF_DEFAULT; api.type = ZEBRA_ROUTE_OSPF; api.instance = ospf->instance; api.flags = ZEBRA_FLAG_BLACKHOLE; @@ -741,8 +756,9 @@ int ospf_is_type_redistributed (int type, u_short instance) { return (DEFAULT_ROUTE_TYPE (type) ? - zclient->default_information : - redist_check_instance(&zclient->redist[AFI_IP][type], instance)); + vrf_bitmap_check (zclient->default_information, VRF_DEFAULT) : + ((instance && redist_check_instance(&zclient->mi_redist[AFI_IP][type], instance)) + || vrf_bitmap_check (zclient->redist[AFI_IP][type], VRF_DEFAULT))); } int @@ -782,7 +798,8 @@ ospf_redistribute_set (struct ospf *ospf, int type, u_short instance, int mtype, ospf_external_add(type, instance); - zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, instance); + zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, + instance, VRF_DEFAULT); if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) zlog_debug ("Redistribute[%s][%d]: Start Type[%d], Metric[%d]", @@ -803,7 +820,8 @@ ospf_redistribute_unset (struct ospf *ospf, int type, u_short instance) if (!ospf_is_type_redistributed (type, instance)) return CMD_SUCCESS; - zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, instance); + zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, + instance, VRF_DEFAULT); if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) zlog_debug ("Redistribute[%s][%d]: Stop", @@ -850,7 +868,8 @@ ospf_redistribute_default_set (struct ospf *ospf, int originate, return CMD_SUCCESS; } - zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient); + zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient, + VRF_DEFAULT); if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) zlog_debug ("Redistribute[DEFAULT]: Start Type[%d], Metric[%d]", @@ -876,7 +895,8 @@ ospf_redistribute_default_unset (struct ospf *ospf) ospf->default_originate = DEFAULT_ORIGINATE_NONE; ospf_redist_del(ospf, DEFAULT_ROUTE, 0); - zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, zclient); + zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, zclient, + VRF_DEFAULT); if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) zlog_debug ("Redistribute[DEFAULT]: Stop"); @@ -1015,7 +1035,7 @@ ospf_routemap_unset (struct ospf_redist *red) /* Zebra route add and delete treatment. */ static int ospf_zebra_read_ipv4 (int command, struct zclient *zclient, - zebra_size_t length) + zebra_size_t length, vrf_id_t vrf_id) { struct stream *s; struct zapi_ipv4 api; @@ -1545,12 +1565,19 @@ ospf_distance_apply (struct prefix_ipv4 *p, struct ospf_route *or) return 0; } +static void +ospf_zebra_connected (struct zclient *zclient) +{ + zclient_send_requests (zclient, VRF_DEFAULT); +} + void ospf_zebra_init (struct thread_master *master, u_short instance) { /* Allocate zebra structure. */ zclient = zclient_new(master); zclient_init (zclient, ZEBRA_ROUTE_OSPF, instance); + zclient->zebra_connected = ospf_zebra_connected; zclient->router_id_update = ospf_router_id_update_zebra; zclient->interface_add = ospf_interface_add; zclient->interface_delete = ospf_interface_delete; |