}
}
-/* Inteface addition message from zebra. */
-static int bgp_interface_add(ZAPI_CALLBACK_ARGS)
+static int bgp_ifp_destroy(struct interface *ifp)
{
- struct interface *ifp;
struct bgp *bgp;
- ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
- if (!ifp) // unexpected
- return 0;
-
- if (BGP_DEBUG(zebra, ZEBRA) && ifp)
- zlog_debug("Rx Intf add VRF %u IF %s", vrf_id, ifp->name);
-
- bgp = bgp_lookup_by_vrf_id(vrf_id);
- if (!bgp)
- return 0;
-
- bgp_mac_add_mac_entry(ifp);
-
- bgp_update_interface_nbrs(bgp, ifp, ifp);
- return 0;
-}
-
-static int bgp_interface_delete(ZAPI_CALLBACK_ARGS)
-{
- struct stream *s;
- struct interface *ifp;
- struct bgp *bgp;
-
- bgp = bgp_lookup_by_vrf_id(vrf_id);
-
- s = zclient->ibuf;
- ifp = zebra_interface_state_read(s, vrf_id);
- if (!ifp) /* This may happen if we've just unregistered for a VRF. */
- return 0;
+ bgp = bgp_lookup_by_vrf_id(ifp->vrf_id);
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("Rx Intf del VRF %u IF %s", vrf_id, ifp->name);
+ zlog_debug("Rx Intf del VRF %u IF %s", ifp->vrf_id, ifp->name);
if (bgp)
bgp_update_interface_nbrs(bgp, ifp, NULL);
bgp_mac_del_mac_entry(ifp);
- if_set_index(ifp, IFINDEX_INTERNAL);
return 0;
}
-static int bgp_interface_up(ZAPI_CALLBACK_ARGS)
+static int bgp_ifp_up(struct interface *ifp)
{
- struct stream *s;
- struct interface *ifp;
struct connected *c;
struct nbr_connected *nc;
struct listnode *node, *nnode;
struct bgp *bgp;
- bgp = bgp_lookup_by_vrf_id(vrf_id);
-
- s = zclient->ibuf;
- ifp = zebra_interface_state_read(s, vrf_id);
-
- if (!ifp)
- return 0;
+ bgp = bgp_lookup_by_vrf_id(ifp->vrf_id);
bgp_mac_add_mac_entry(ifp);
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("Rx Intf up VRF %u IF %s", vrf_id, ifp->name);
+ zlog_debug("Rx Intf up VRF %u IF %s", ifp->vrf_id, ifp->name);
if (!bgp)
return 0;
return 0;
}
-static int bgp_interface_down(ZAPI_CALLBACK_ARGS)
+static int bgp_ifp_down(struct interface *ifp)
{
- struct stream *s;
- struct interface *ifp;
struct connected *c;
struct nbr_connected *nc;
struct listnode *node, *nnode;
struct bgp *bgp;
struct peer *peer;
- bgp = bgp_lookup_by_vrf_id(vrf_id);
-
- s = zclient->ibuf;
- ifp = zebra_interface_state_read(s, vrf_id);
- if (!ifp)
- return 0;
+ bgp = bgp_lookup_by_vrf_id(ifp->vrf_id);
bgp_mac_del_mac_entry(ifp);
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("Rx Intf down VRF %u IF %s", vrf_id, ifp->name);
+ zlog_debug("Rx Intf down VRF %u IF %s", ifp->vrf_id, ifp->name);
if (!bgp)
return 0;
}
}
- if_update_to_new_vrf(ifp, vrf_lookup_by_id(new_vrf_id));
+ if_update_to_new_vrf(ifp, new_vrf_id);
bgp = bgp_lookup_by_vrf_id(new_vrf_id);
if (!bgp)
nexthop->v4 = local->sin.sin_addr;
if (peer->update_if)
ifp = if_lookup_by_name(peer->update_if,
- vrf_lookup_by_id(peer->bgp->vrf_id));
+ peer->bgp->vrf_id);
else
ifp = if_lookup_by_ipv4_exact(&local->sin.sin_addr,
peer->bgp->vrf_id);
ifp = if_lookup_by_name(peer->conf_if
? peer->conf_if
: peer->ifname,
- vrf_lookup_by_id(
- peer->bgp->vrf_id));
+ peer->bgp->vrf_id);
} else if (peer->update_if)
ifp = if_lookup_by_name(peer->update_if,
- vrf_lookup_by_id(peer->bgp->vrf_id));
+ peer->bgp->vrf_id);
else
ifp = if_lookup_by_ipv6_exact(&local->sin6.sin6_addr,
local->sin6.sin6_scope_id,
SET_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION);
+ if (info->attr->rmap_table_id) {
+ SET_FLAG(api.message, ZAPI_MESSAGE_TABLEID);
+ api.tableid = info->attr->rmap_table_id;
+ }
+
/* Metric is currently based on the best-path only */
metric = info->attr->med;
for (mpinfo = info; mpinfo; mpinfo = bgp_path_info_mpath_next(mpinfo)) {
api.safi = safi;
api.prefix = *p;
+ if (info->attr->rmap_table_id) {
+ SET_FLAG(api.message, ZAPI_MESSAGE_TABLEID);
+ api.tableid = info->attr->rmap_table_id;
+ }
+
/* If the route's source is EVPN, flag as such. */
if (is_route_parent_evpn(info))
SET_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE);
stream_putw(s, pbm->tcp_mask_flags);
stream_putc(s, pbm->dscp_value);
stream_putc(s, pbm->fragment);
+ stream_putc(s, pbm->protocol);
}
/* BGP has established connection with Zebra. */
extern struct zebra_privs_t bgpd_privs;
+static int bgp_ifp_create(struct interface *ifp)
+{
+ struct bgp *bgp;
+
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("Rx Intf add VRF %u IF %s", ifp->vrf_id, ifp->name);
+
+ bgp = bgp_lookup_by_vrf_id(ifp->vrf_id);
+ if (!bgp)
+ return 0;
+
+ bgp_mac_add_mac_entry(ifp);
+
+ bgp_update_interface_nbrs(bgp, ifp, ifp);
+ return 0;
+}
+
void bgp_zebra_init(struct thread_master *master, unsigned short instance)
{
zclient_num_connects = 0;
+ if_zapi_callbacks(bgp_ifp_create, bgp_ifp_up,
+ bgp_ifp_down, bgp_ifp_destroy);
+
/* Set default values. */
zclient = zclient_new(master, &zclient_options_default);
zclient_init(zclient, ZEBRA_ROUTE_BGP, 0, &bgpd_privs);
zclient->zebra_connected = bgp_zebra_connected;
zclient->router_id_update = bgp_router_id_update;
- zclient->interface_add = bgp_interface_add;
- zclient->interface_delete = bgp_interface_delete;
zclient->interface_address_add = bgp_interface_address_add;
zclient->interface_address_delete = bgp_interface_address_delete;
zclient->interface_nbr_address_add = bgp_interface_nbr_address_add;
zclient->interface_vrf_update = bgp_interface_vrf_update;
zclient->redistribute_route_add = zebra_read_route;
zclient->redistribute_route_del = zebra_read_route;
- zclient->interface_up = bgp_interface_up;
- zclient->interface_down = bgp_interface_down;
zclient->nexthop_update = bgp_read_nexthop_update;
zclient->import_check_update = bgp_read_import_check_update;
zclient->fec_update = bgp_read_fec_update;
head = &(bgp_pbr_cfg->ifaces_by_name_ipv4);
RB_FOREACH (pbr_if, bgp_pbr_interface_head, head) {
- ifp = if_lookup_by_name(pbr_if->name,
- vrf_lookup_by_id(bgp->vrf_id));
+ ifp = if_lookup_by_name(pbr_if->name, bgp->vrf_id);
if (ifp)
stream_putl(s, ifp->ifindex);
}
head = &(bgp_pbr_cfg->ifaces_by_name_ipv4);
RB_FOREACH (pbr_if, bgp_pbr_interface_head, head) {
- if (if_lookup_by_name(pbr_if->name,
- vrf_lookup_by_id(bgp->vrf_id)))
+ if (if_lookup_by_name(pbr_if->name, bgp->vrf_id))
cnt++;
}
return cnt;