Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zebra: Enhancements for rtm_table field in FPM netlink message #4365

Merged
merged 1 commit into from
May 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions zebra/zebra_fpm_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,17 @@ static int netlink_route_info_fill(netlink_route_info_t *ri, int cmd,
rib_dest_t *dest, struct route_entry *re)
{
struct nexthop *nexthop;
struct zebra_vrf *zvrf;

memset(ri, 0, sizeof(*ri));

ri->prefix = rib_dest_prefix(dest);
ri->af = rib_dest_af(dest);

ri->nlmsg_type = cmd;
ri->rtm_table = zvrf_id(rib_dest_vrf(dest));
zvrf = rib_dest_vrf(dest);
if (zvrf)
ri->rtm_table = zvrf->table_id;
ri->rtm_protocol = RTPROT_UNSPEC;

/*
Expand Down Expand Up @@ -327,7 +330,21 @@ static int netlink_route_info_encode(netlink_route_info_t *ri, char *in_buf,
req->n.nlmsg_flags = NLM_F_CREATE | NLM_F_REQUEST;
req->n.nlmsg_type = ri->nlmsg_type;
req->r.rtm_family = ri->af;
req->r.rtm_table = ri->rtm_table;

/*
* rtm_table field is a uchar field which can accomodate table_id less
* than 256.
* To support table id greater than 255, if the table_id is greater than
* 255, set rtm_table to RT_TABLE_UNSPEC and add RTA_TABLE attribute
* with 32 bit value as the table_id.
*/
if (ri->rtm_table < 256)
req->r.rtm_table = ri->rtm_table;
else {
req->r.rtm_table = RT_TABLE_UNSPEC;
addattr32(&req->n, in_buf_len, RTA_TABLE, ri->rtm_table);
}

req->r.rtm_dst_len = ri->prefix->prefixlen;
req->r.rtm_protocol = ri->rtm_protocol;
req->r.rtm_scope = RT_SCOPE_UNIVERSE;
Expand Down