Skip to content

pattr: fixed ipv6 routes sending #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/bgp-afi.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace libbgp {
*
*/
enum Afi {
UNKNOWN_AFI = 0,
IPV4 = 1,
IPV6 = 2
};
Expand All @@ -27,11 +28,12 @@ enum Afi {
*
*/
enum Safi {
UNKNOWN_SAFI = 0,
UNICAST = 1,
MULTICAST = 2,
UNICAST_AND_MULTICAST = 3
};

};

#endif // BGP_AFI_H_
#endif // BGP_AFI_H_
17 changes: 11 additions & 6 deletions src/bgp-fsm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ bool BgpFsm::handleRoute6AddEvent(const Route6AddEvent &ev) {
std::vector<Prefix6> routes;
const uint8_t *nh_global = ev.nexthop_global;
const uint8_t *nh_local = ev.nexthop_linklocal;
alterNexthop6(nh_local, nh_global);
alterNexthop6(nh_global, nh_local);

for (const Prefix6 &route : *(ev.new_routes)) {
if (config.out_filters6.apply(route, *(ev.shared_attribs))) {
Expand Down Expand Up @@ -565,7 +565,7 @@ bool BgpFsm::handleRoute6AddEvent(const Route6AddEvent &ev) {
update.setAttribs(entry.attribs);
const uint8_t *nh_global = entry.nexthop_global;
const uint8_t *nh_local = entry.nexthop_linklocal;
alterNexthop6(nh_local, nh_global);
alterNexthop6(nh_global, nh_local);
std::vector<Prefix6> routes;
routes.push_back(entry.route);
update.setNlri6(routes, nh_global, nh_local);
Expand Down Expand Up @@ -722,17 +722,22 @@ void BgpFsm::alterNexthop4 (BgpUpdateMessage &update) {
}

void BgpFsm::alterNexthop6 (const uint8_t* &nh_global, const uint8_t* &nh_local) {
if (config.forced_default_nexthop6 && !config.peering_lan6.includes(nh_global) && !ibgp && !config.ibgp_alter_nexthop) {
// ibgp
if (ibgp && !config.ibgp_alter_nexthop) return;

if (config.forced_default_nexthop6 || !config.peering_lan6.includes(nh_global)) {
LIBBGP_LOG(logger, INFO) {
char nh_old_str[INET6_ADDRSTRLEN];
char nh_def_str[INET6_ADDRSTRLEN];
char nh_def_ll_str[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, &nh_global, nh_old_str, INET6_ADDRSTRLEN);
inet_ntop(AF_INET6, &nh_def_str, nh_def_str, INET6_ADDRSTRLEN);
inet_ntop(AF_INET6, &config.default_nexthop6_global, nh_def_str, INET6_ADDRSTRLEN);
inet_ntop(AF_INET6, &config.default_nexthop6_linklocal, nh_def_ll_str, INET6_ADDRSTRLEN);

if (config.forced_default_nexthop6) {
logger->log(INFO, "BgpFsm::alterNexthop6: forced_default_nexthop6 set, default (%s) will be used.\n", nh_def_str);
logger->log(INFO, "BgpFsm::alterNexthop6: forced_default_nexthop6 set, default (%s) and link local (%s) will be used.\n", nh_def_str, nh_def_ll_str);
}
else logger->log(INFO, "BgpFsm::alterNexthop6: nexthop %s is not in peering lan, default (%s) will be used.\n", nh_old_str, nh_def_str);
else logger->log(INFO, "BgpFsm::alterNexthop6: nexthop %s is not in peering lan, default (%s) and link local (%s) will be used.\n", nh_old_str, nh_def_str, nh_def_ll_str);
}

nh_global = config.default_nexthop6_global;
Expand Down
Loading