diff options
| author | Tuetuopay <tuetuopay@me.com> | 2025-03-14 20:21:46 +0100 |
|---|---|---|
| committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2025-03-23 12:49:09 +0200 |
| commit | 5960447611b8665a9a967af61e34296255644dc9 (patch) | |
| tree | 4a5ff630b68c693a1a3124a23c89ee7f6de2b249 | |
| parent | 24e51889e8605a9dbbb65b80464ebc4185a0abd8 (diff) | |
bgpd: fix `set evpn gateway-ip ipv[46]` route-map
The `route_set_evpn_gateway_ip` function copies `gw_ip->ip.addr` in the
route's gateway ip. In a nutshell, this skips the `ipa_type` field,
writing the actual IP in the IP type. This later rightfully trips
asserts about unknown IP types.
The following route-map...
```
route-map test permit 10
set evpn gateway-ip ipv4 1.1.1.1
```
...will make the following gateway IP in the route:
```
(gdb) p/x a1->evpn_overlay->gw_ip
$11 = {ipa_type = 0x1010101, ip = {addr = 0x0, addrbytes = {
0x0 <repeats 16 times>}, _v4_addr = {s_addr = 0x0}, _v6_addr = {
__in6_u = {__u6_addr8 = {0x0 <repeats 16 times>}, __u6_addr16 = {0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, __u6_addr32 = {0x0, 0x0, 0x0,
0x0}}}}}
```
We do indeed see the IP Address in the `ipa_type` field.
Fix by starting the memcpy at the root of `struct ipaddr` instead of
skipping the `ipa_type` field.
Fixes: d0a4ee6010a ("bgpd: Add "set evpn gateway-ip" clause for route-map")
Signed-off-by: Tuetuopay <tuetuopay@me.com>
(cherry picked from commit 0b0e7015971a788c14dd1dc9b5bac8cb66175c29)
| -rw-r--r-- | bgpd/bgp_routemap.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index fe6faffa6e..728a30ac81 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -1256,8 +1256,7 @@ route_set_evpn_gateway_ip(void *rule, const struct prefix *prefix, void *object) /* Set gateway-ip value. */ path->attr->evpn_overlay.type = OVERLAY_INDEX_GATEWAY_IP; - memcpy(&path->attr->evpn_overlay.gw_ip, &gw_ip->ip.addr, - IPADDRSZ(gw_ip)); + path->attr->evpn_overlay.gw_ip = *gw_ip; return RMAP_OKAY; } |
