From fae109213ebcf15a5d537f40f21fdee3ad2dafa5 Mon Sep 17 00:00:00 2001 From: Nikhil Kelapure Date: Mon, 13 Sep 2021 09:45:03 -0700 Subject: [PATCH 1/4] Description: Currently IPv4 routes with IPv6 link local next hops are not properly installed in FPM. Reason is the netlink decoding truncates the ipv6 LL address to 4 byte ipv4 address. Ex : fe80:: is directly converted to ipv4 and it results in 254.128.0.0 as next hop for below routes show ip route Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, F - PBR, f - OpenFabric, > - selected route, * - FIB route, q - queued, r - rejected, b - backup B>* 2.1.0.0/16 [200/0] via fe80::268a:7ff:fed0:d40, Ethernet0, weight 1, 02:22:26 B>* 5.1.0.0/16 [200/0] via fe80::268a:7ff:fed0:d40, Ethernet0, weight 1, 02:22:26 B>* 10.1.0.2/32 [200/0] via fe80::268a:7ff:fed0:d40, Ethernet0, weight 1, 02:22:26 Hence this fix converts the ipv6-LL address to ipv4-LL (169.254.0.1) address before sending it to FPM. This is inline with how these types of routes are currently programmed into kernel. Signed-off-by: Nikhil Kelapure --- ...-address-for-Ipv6-linl-local-nexthop.patch | 55 +++++++++++++++++++ src/sonic-frr/patch/series | 1 + 2 files changed, 56 insertions(+) create mode 100644 src/sonic-frr/patch/0010-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch diff --git a/src/sonic-frr/patch/0010-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch b/src/sonic-frr/patch/0010-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch new file mode 100644 index 000000000000..7a041c02fe15 --- /dev/null +++ b/src/sonic-frr/patch/0010-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch @@ -0,0 +1,55 @@ +diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c +index 7b0611bf9..b5582ea35 100644 +--- a/zebra/zebra_fpm.c ++++ b/zebra/zebra_fpm.c +@@ -288,6 +288,9 @@ static void zfpm_start_connect_timer(const char *reason); + static void zfpm_start_stats_timer(void); + static void zfpm_mac_info_del(struct fpm_mac_info_t *fpm_mac); + ++static const char ipv4_ll_buf[16] = "169.254.0.1"; ++union g_addr ipv4ll_gateway; ++ + /* + * zfpm_thread_should_yield + */ +@@ -1988,6 +1991,9 @@ static int zfpm_init(struct thread_master *master) + zfpm_stats_init(&zfpm_g->last_ivl_stats); + zfpm_stats_init(&zfpm_g->cumulative_stats); + ++ memset(&ipv4ll_gateway, 0, sizeof(ipv4ll_gateway)); ++ inet_pton(AF_INET, ipv4_ll_buf, &ipv4ll_gateway.ipv4); ++ + install_node(&zebra_node); + install_element(ENABLE_NODE, &show_zebra_fpm_stats_cmd); + install_element(ENABLE_NODE, &clear_zebra_fpm_stats_cmd); +diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c +index 60ea7f97e..0f8ba5413 100644 +--- a/zebra/zebra_fpm_netlink.c ++++ b/zebra/zebra_fpm_netlink.c +@@ -221,7 +221,12 @@ static int netlink_route_info_add_nh(struct netlink_route_info *ri, + + if (nexthop->type == NEXTHOP_TYPE_IPV6 + || nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) { +- nhi.gateway = &nexthop->gate; ++ /* Special handling for IPv4 route with IPv6 Link Local next hop ++ */ ++ if (ri->af == AF_INET) ++ nhi.gateway = &ipv4ll_gateway; ++ else ++ nhi.gateway = &nexthop->gate; + } + + if (nexthop->type == NEXTHOP_TYPE_IFINDEX) { +diff --git a/zebra/zebra_fpm_private.h b/zebra/zebra_fpm_private.h +index c169ee8c2..13415c7e1 100644 +--- a/zebra/zebra_fpm_private.h ++++ b/zebra/zebra_fpm_private.h +@@ -97,6 +97,8 @@ extern int zfpm_netlink_encode_mac(struct fpm_mac_info_t *mac, char *in_buf, + + extern struct route_entry *zfpm_route_for_update(rib_dest_t *dest); + ++extern union g_addr ipv4ll_gateway; ++ + #ifdef __cplusplus + } + #endif diff --git a/src/sonic-frr/patch/series b/src/sonic-frr/patch/series index 2837a79f249a..a893f5cc896f 100644 --- a/src/sonic-frr/patch/series +++ b/src/sonic-frr/patch/series @@ -7,3 +7,4 @@ 0008-Add-support-of-bgp-l3vni-evpn.patch 0009-Add-bgp-bestpath-peer-type-multipath-relax.patch 0009-Link-local-scope-was-not-set-while-binding-socket-for-bgp-ipv6-link-local-neighbors.patch +0010-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch From 1675cf8ce55bd24d56c132f9dcb787cff5d8cb60 Mon Sep 17 00:00:00 2001 From: Nikhil Kelapure Date: Mon, 13 Sep 2021 09:45:03 -0700 Subject: [PATCH 2/4] Description: Currently IPv4 routes with IPv6 link local next hops are not properly installed in FPM. Reason is the netlink decoding truncates the ipv6 LL address to 4 byte ipv4 address. Ex : fe80:: is directly converted to ipv4 and it results in 254.128.0.0 as next hop for below routes show ip route Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, F - PBR, f - OpenFabric, > - selected route, * - FIB route, q - queued, r - rejected, b - backup B>* 2.1.0.0/16 [200/0] via fe80::268a:7ff:fed0:d40, Ethernet0, weight 1, 02:22:26 B>* 5.1.0.0/16 [200/0] via fe80::268a:7ff:fed0:d40, Ethernet0, weight 1, 02:22:26 B>* 10.1.0.2/32 [200/0] via fe80::268a:7ff:fed0:d40, Ethernet0, weight 1, 02:22:26 Hence this fix converts the ipv6-LL address to ipv4-LL (169.254.0.1) address before sending it to FPM. This is inline with how these types of routes are currently programmed into kernel. Signed-off-by: Nikhil Kelapure --- ...-address-for-Ipv6-linl-local-nexthop.patch | 55 +++++++++++++++++++ src/sonic-frr/patch/series | 2 +- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/sonic-frr/patch/0011-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch diff --git a/src/sonic-frr/patch/0011-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch b/src/sonic-frr/patch/0011-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch new file mode 100644 index 000000000000..7a041c02fe15 --- /dev/null +++ b/src/sonic-frr/patch/0011-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch @@ -0,0 +1,55 @@ +diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c +index 7b0611bf9..b5582ea35 100644 +--- a/zebra/zebra_fpm.c ++++ b/zebra/zebra_fpm.c +@@ -288,6 +288,9 @@ static void zfpm_start_connect_timer(const char *reason); + static void zfpm_start_stats_timer(void); + static void zfpm_mac_info_del(struct fpm_mac_info_t *fpm_mac); + ++static const char ipv4_ll_buf[16] = "169.254.0.1"; ++union g_addr ipv4ll_gateway; ++ + /* + * zfpm_thread_should_yield + */ +@@ -1988,6 +1991,9 @@ static int zfpm_init(struct thread_master *master) + zfpm_stats_init(&zfpm_g->last_ivl_stats); + zfpm_stats_init(&zfpm_g->cumulative_stats); + ++ memset(&ipv4ll_gateway, 0, sizeof(ipv4ll_gateway)); ++ inet_pton(AF_INET, ipv4_ll_buf, &ipv4ll_gateway.ipv4); ++ + install_node(&zebra_node); + install_element(ENABLE_NODE, &show_zebra_fpm_stats_cmd); + install_element(ENABLE_NODE, &clear_zebra_fpm_stats_cmd); +diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c +index 60ea7f97e..0f8ba5413 100644 +--- a/zebra/zebra_fpm_netlink.c ++++ b/zebra/zebra_fpm_netlink.c +@@ -221,7 +221,12 @@ static int netlink_route_info_add_nh(struct netlink_route_info *ri, + + if (nexthop->type == NEXTHOP_TYPE_IPV6 + || nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) { +- nhi.gateway = &nexthop->gate; ++ /* Special handling for IPv4 route with IPv6 Link Local next hop ++ */ ++ if (ri->af == AF_INET) ++ nhi.gateway = &ipv4ll_gateway; ++ else ++ nhi.gateway = &nexthop->gate; + } + + if (nexthop->type == NEXTHOP_TYPE_IFINDEX) { +diff --git a/zebra/zebra_fpm_private.h b/zebra/zebra_fpm_private.h +index c169ee8c2..13415c7e1 100644 +--- a/zebra/zebra_fpm_private.h ++++ b/zebra/zebra_fpm_private.h +@@ -97,6 +97,8 @@ extern int zfpm_netlink_encode_mac(struct fpm_mac_info_t *mac, char *in_buf, + + extern struct route_entry *zfpm_route_for_update(rib_dest_t *dest); + ++extern union g_addr ipv4ll_gateway; ++ + #ifdef __cplusplus + } + #endif diff --git a/src/sonic-frr/patch/series b/src/sonic-frr/patch/series index a893f5cc896f..f78eca231eb8 100644 --- a/src/sonic-frr/patch/series +++ b/src/sonic-frr/patch/series @@ -7,4 +7,4 @@ 0008-Add-support-of-bgp-l3vni-evpn.patch 0009-Add-bgp-bestpath-peer-type-multipath-relax.patch 0009-Link-local-scope-was-not-set-while-binding-socket-for-bgp-ipv6-link-local-neighbors.patch -0010-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch +0011-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch From cb89cbae28ebab95cc46c197ef6cf324f0c2ddd3 Mon Sep 17 00:00:00 2001 From: nkelapur Date: Tue, 14 Dec 2021 11:17:15 +0530 Subject: [PATCH 3/4] Delete 0010-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch --- ...-address-for-Ipv6-linl-local-nexthop.patch | 55 ------------------- 1 file changed, 55 deletions(-) delete mode 100644 src/sonic-frr/patch/0010-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch diff --git a/src/sonic-frr/patch/0010-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch b/src/sonic-frr/patch/0010-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch deleted file mode 100644 index 7a041c02fe15..000000000000 --- a/src/sonic-frr/patch/0010-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch +++ /dev/null @@ -1,55 +0,0 @@ -diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c -index 7b0611bf9..b5582ea35 100644 ---- a/zebra/zebra_fpm.c -+++ b/zebra/zebra_fpm.c -@@ -288,6 +288,9 @@ static void zfpm_start_connect_timer(const char *reason); - static void zfpm_start_stats_timer(void); - static void zfpm_mac_info_del(struct fpm_mac_info_t *fpm_mac); - -+static const char ipv4_ll_buf[16] = "169.254.0.1"; -+union g_addr ipv4ll_gateway; -+ - /* - * zfpm_thread_should_yield - */ -@@ -1988,6 +1991,9 @@ static int zfpm_init(struct thread_master *master) - zfpm_stats_init(&zfpm_g->last_ivl_stats); - zfpm_stats_init(&zfpm_g->cumulative_stats); - -+ memset(&ipv4ll_gateway, 0, sizeof(ipv4ll_gateway)); -+ inet_pton(AF_INET, ipv4_ll_buf, &ipv4ll_gateway.ipv4); -+ - install_node(&zebra_node); - install_element(ENABLE_NODE, &show_zebra_fpm_stats_cmd); - install_element(ENABLE_NODE, &clear_zebra_fpm_stats_cmd); -diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c -index 60ea7f97e..0f8ba5413 100644 ---- a/zebra/zebra_fpm_netlink.c -+++ b/zebra/zebra_fpm_netlink.c -@@ -221,7 +221,12 @@ static int netlink_route_info_add_nh(struct netlink_route_info *ri, - - if (nexthop->type == NEXTHOP_TYPE_IPV6 - || nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) { -- nhi.gateway = &nexthop->gate; -+ /* Special handling for IPv4 route with IPv6 Link Local next hop -+ */ -+ if (ri->af == AF_INET) -+ nhi.gateway = &ipv4ll_gateway; -+ else -+ nhi.gateway = &nexthop->gate; - } - - if (nexthop->type == NEXTHOP_TYPE_IFINDEX) { -diff --git a/zebra/zebra_fpm_private.h b/zebra/zebra_fpm_private.h -index c169ee8c2..13415c7e1 100644 ---- a/zebra/zebra_fpm_private.h -+++ b/zebra/zebra_fpm_private.h -@@ -97,6 +97,8 @@ extern int zfpm_netlink_encode_mac(struct fpm_mac_info_t *mac, char *in_buf, - - extern struct route_entry *zfpm_route_for_update(rib_dest_t *dest); - -+extern union g_addr ipv4ll_gateway; -+ - #ifdef __cplusplus - } - #endif From 78d703e4e6b3ed0e8b92d47ef0ccb069c7814fdd Mon Sep 17 00:00:00 2001 From: nkelapur Date: Tue, 14 Dec 2021 11:17:43 +0530 Subject: [PATCH 4/4] Update series --- src/sonic-frr/patch/series | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-frr/patch/series b/src/sonic-frr/patch/series index 2be7129f3636..b77931d57e9a 100644 --- a/src/sonic-frr/patch/series +++ b/src/sonic-frr/patch/series @@ -8,4 +8,4 @@ 0009-Add-bgp-bestpath-peer-type-multipath-relax.patch 0009-Link-local-scope-was-not-set-while-binding-socket-for-bgp-ipv6-link-local-neighbors.patch 0010-remove-doc-png-install.patch -0011-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch \ No newline at end of file +0011-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch