Skip to content

Commit

Permalink
Merge pull request #17071 from louis-6wind/fix-ipv6-ll-nexthop-unchanged
Browse files Browse the repository at this point in the history
bgpd: split nexthop-local unchanged peer subgroup
  • Loading branch information
ton31337 authored Oct 13, 2024
2 parents adc0f00 + 1005c14 commit 129c652
Show file tree
Hide file tree
Showing 23 changed files with 1,648 additions and 93 deletions.
16 changes: 16 additions & 0 deletions bgpd/bgp_updgrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,10 @@ static unsigned int updgrp_hash_key_make(const void *p)
key = jhash_1word(jhash(soo_str, strlen(soo_str), SEED1), key);
}

if (afi == AFI_IP6 &&
(CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)))
key = jhash(&peer->nexthop.v6_global, IPV6_MAX_BYTELEN, key);

/*
* ANY NEW ITEMS THAT ARE ADDED TO THE key, ENSURE DEBUG
* STATEMENT STAYS UP TO DATE
Expand Down Expand Up @@ -521,6 +525,12 @@ static unsigned int updgrp_hash_key_make(const void *p)
peer->soo[afi][safi]
? ecommunity_str(peer->soo[afi][safi])
: "(NONE)");
zlog_debug("%pBP Update Group Hash: IPv6 nexthop-local unchanged: %d IPv6 global %pI6",
peer,
afi == AFI_IP6 && (CHECK_FLAG(peer->af_flags[afi][safi],
PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)),
&peer->nexthop.v6_global);

zlog_debug("%pBP Update Group Hash key: %u", peer, key);
}
return key;
Expand Down Expand Up @@ -655,6 +665,12 @@ static bool updgrp_hash_cmp(const void *p1, const void *p2)
!sockunion_same(&pe1->connection->su, &pe2->connection->su))
return false;

if (afi == AFI_IP6 &&
(CHECK_FLAG(flags1, PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) ||
CHECK_FLAG(flags2, PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) &&
!IPV6_ADDR_SAME(&pe1->nexthop.v6_global, &pe2->nexthop.v6_global))
return false;

return true;
}

Expand Down
64 changes: 56 additions & 8 deletions tests/topotests/bgp_nexthop_ipv6/r1/show_bgp_ipv6_step1.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@
"ip": "fd00:0:2::2",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:r2:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand All @@ -48,7 +54,13 @@
"ip": "fd00:0:2::4",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:r4:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand All @@ -61,7 +73,13 @@
"ip": "fd00:0:3::5",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:rr:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand All @@ -74,7 +92,13 @@
"ip": "fd00:0:4::6",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:rr:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand All @@ -100,7 +124,13 @@
"ip": "fd00:0:2::2",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:r2:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand All @@ -126,7 +156,13 @@
"ip": "fd00:0:2::4",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:r4:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand All @@ -139,7 +175,13 @@
"ip": "fd00:0:3::5",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:rr:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand All @@ -152,7 +194,13 @@
"ip": "fd00:0:4::6",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:rr:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand Down
64 changes: 56 additions & 8 deletions tests/topotests/bgp_nexthop_ipv6/r2/show_bgp_ipv6_step1.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
"ip": "fd00:0:2::1",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:r1:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand Down Expand Up @@ -48,7 +54,13 @@
"ip": "fd00:0:2::4",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:r4:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand All @@ -61,7 +73,13 @@
"ip": "fd00:0:3::5",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:rr:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand All @@ -74,7 +92,13 @@
"ip": "fd00:0:4::6",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:rr:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand All @@ -87,7 +111,13 @@
"ip": "fd00:0:2::1",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:r1:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand Down Expand Up @@ -126,7 +156,13 @@
"ip": "fd00:0:2::4",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:r4:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand All @@ -139,7 +175,13 @@
"ip": "fd00:0:3::5",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:rr:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand All @@ -152,7 +194,13 @@
"ip": "fd00:0:4::6",
"hostname": "rr",
"afi": "ipv6",
"scope": "global",
"scope": "global"
},
{
"ip": "link-local:rr:eth-sw",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"used": true
}
]
Expand Down
16 changes: 2 additions & 14 deletions tests/topotests/bgp_nexthop_ipv6/r5/show_bgp_ipv6_step1.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@
"ip": "fd00:0:3::9",
"hostname": "rr",
"afi": "ipv6",
"scope": "global"
},
{
"ip": "link-local:rr:eth-r5",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"scope": "global",
"used": true
}
]
Expand Down Expand Up @@ -155,13 +149,7 @@
"ip": "fd00:0:3::9",
"hostname": "rr",
"afi": "ipv6",
"scope": "global"
},
{
"ip": "link-local:rr:eth-r5",
"hostname": "rr",
"afi": "ipv6",
"scope": "link-local",
"scope": "global",
"used": true
}
]
Expand Down
Loading

0 comments on commit 129c652

Please sign in to comment.