diff options
| author | Ameya Dharkar <adharkar@vmware.com> | 2019-05-17 12:47:57 -0700 |
|---|---|---|
| committer | root <root@dev.vmware.com> | 2019-05-17 14:07:56 -0700 |
| commit | 6dfcd75461ff35ebf89e86f64fe6e982ed09b3e3 (patch) | |
| tree | 990414e92a555db755046685a7337884ab508e2e | |
| parent | 02f4c3ab5b33f5f17b592ef7787797a0e43d0785 (diff) | |
Zebra: Enhancements for rtm_table field in FPM netlink message
- Today, rtm_table field takes a vrf_id. It should take table_id
- rtm_table field is a uchar field which can only 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 0 and add RTA_TABLE attribute with 32 bit value as the
table_id.
Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
| -rw-r--r-- | zebra/zebra_fpm_netlink.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index 065bdee208..04df6ce423 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -224,6 +224,7 @@ 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)); @@ -231,7 +232,9 @@ static int netlink_route_info_fill(netlink_route_info_t *ri, int cmd, 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; /* @@ -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; |
