Skip to content

Commit 9b93749

Browse files
authored
Fix IPv4 routes with IPv6 link local next hops installed in FPM (#8740)
* 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 <[email protected]>
1 parent 5fb21ce commit 9b93749

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c
2+
index 7b0611bf9..b5582ea35 100644
3+
--- a/zebra/zebra_fpm.c
4+
+++ b/zebra/zebra_fpm.c
5+
@@ -288,6 +288,9 @@ static void zfpm_start_connect_timer(const char *reason);
6+
static void zfpm_start_stats_timer(void);
7+
static void zfpm_mac_info_del(struct fpm_mac_info_t *fpm_mac);
8+
9+
+static const char ipv4_ll_buf[16] = "169.254.0.1";
10+
+union g_addr ipv4ll_gateway;
11+
+
12+
/*
13+
* zfpm_thread_should_yield
14+
*/
15+
@@ -1988,6 +1991,9 @@ static int zfpm_init(struct thread_master *master)
16+
zfpm_stats_init(&zfpm_g->last_ivl_stats);
17+
zfpm_stats_init(&zfpm_g->cumulative_stats);
18+
19+
+ memset(&ipv4ll_gateway, 0, sizeof(ipv4ll_gateway));
20+
+ inet_pton(AF_INET, ipv4_ll_buf, &ipv4ll_gateway.ipv4);
21+
+
22+
install_node(&zebra_node);
23+
install_element(ENABLE_NODE, &show_zebra_fpm_stats_cmd);
24+
install_element(ENABLE_NODE, &clear_zebra_fpm_stats_cmd);
25+
diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c
26+
index 60ea7f97e..0f8ba5413 100644
27+
--- a/zebra/zebra_fpm_netlink.c
28+
+++ b/zebra/zebra_fpm_netlink.c
29+
@@ -221,7 +221,12 @@ static int netlink_route_info_add_nh(struct netlink_route_info *ri,
30+
31+
if (nexthop->type == NEXTHOP_TYPE_IPV6
32+
|| nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) {
33+
- nhi.gateway = &nexthop->gate;
34+
+ /* Special handling for IPv4 route with IPv6 Link Local next hop
35+
+ */
36+
+ if (ri->af == AF_INET)
37+
+ nhi.gateway = &ipv4ll_gateway;
38+
+ else
39+
+ nhi.gateway = &nexthop->gate;
40+
}
41+
42+
if (nexthop->type == NEXTHOP_TYPE_IFINDEX) {
43+
diff --git a/zebra/zebra_fpm_private.h b/zebra/zebra_fpm_private.h
44+
index c169ee8c2..13415c7e1 100644
45+
--- a/zebra/zebra_fpm_private.h
46+
+++ b/zebra/zebra_fpm_private.h
47+
@@ -97,6 +97,8 @@ extern int zfpm_netlink_encode_mac(struct fpm_mac_info_t *mac, char *in_buf,
48+
49+
extern struct route_entry *zfpm_route_for_update(rib_dest_t *dest);
50+
51+
+extern union g_addr ipv4ll_gateway;
52+
+
53+
#ifdef __cplusplus
54+
}
55+
#endif

src/sonic-frr/patch/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
0009-Add-bgp-bestpath-peer-type-multipath-relax.patch
99
0009-Link-local-scope-was-not-set-while-binding-socket-for-bgp-ipv6-link-local-neighbors.patch
1010
0010-remove-doc-png-install.patch
11+
0011-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch

0 commit comments

Comments
 (0)