diff options
author | Sebastian Benoit <benno@cvs.openbsd.org> | 2018-07-14 12:32:36 +0000 |
---|---|---|
committer | Sebastian Benoit <benno@cvs.openbsd.org> | 2018-07-14 12:32:36 +0000 |
commit | bccfb3f04f9b501d84344c2cd4d45b2892fbbc6d (patch) | |
tree | c238c32b554f656518d008ffb35eadf25aed036b | |
parent | 99c8413410235e3394024f3bd9f7e668d17a5350 (diff) |
get rid of two more implicit ktable_get with rdomain 0.
should not change anything when run in rdomain 0.
ok henning@ phessler@ claudio@
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 6 | ||||
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 6 | ||||
-rw-r--r-- | usr.sbin/bgpd/kroute.c | 48 |
3 files changed, 32 insertions, 28 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index 03dec715288..12a4e6a359c 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.193 2018/07/10 12:40:41 benno Exp $ */ +/* $OpenBSD: bgpd.c,v 1.194 2018/07/14 12:32:35 benno Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -296,7 +296,7 @@ BROKEN if (pledge("stdio rpath wpath cpath fattr unix route recvfd sendfd", } if (pfd[PFD_SOCK_ROUTE].revents & POLLIN) { - if (kr_dispatch_msg() == -1) + if (kr_dispatch_msg(conf->default_tableid) == -1) quit = 1; } @@ -351,7 +351,7 @@ BROKEN if (pledge("stdio rpath wpath cpath fattr unix route recvfd sendfd", control_cleanup(conf->csock); control_cleanup(conf->rcsock); carp_demote_shutdown(); - kr_shutdown(conf->fib_priority); + kr_shutdown(conf->fib_priority, conf->default_tableid); pftable_clear_all(); free_config(conf); diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index 5e6a4eaae26..92ade0493e7 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.325 2018/07/12 21:45:37 benno Exp $ */ +/* $OpenBSD: bgpd.h,v 1.326 2018/07/14 12:32:35 benno Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -1079,13 +1079,13 @@ void ktable_postload(u_int8_t); int ktable_exists(u_int, u_int *); int kr_change(u_int, struct kroute_full *, u_int8_t); int kr_delete(u_int, struct kroute_full *, u_int8_t); -void kr_shutdown(u_int8_t); +void kr_shutdown(u_int8_t, u_int); void kr_fib_couple(u_int, u_int8_t); void kr_fib_couple_all(u_int8_t); void kr_fib_decouple(u_int, u_int8_t); void kr_fib_decouple_all(u_int8_t); void kr_fib_update_prio_all(u_int8_t); -int kr_dispatch_msg(void); +int kr_dispatch_msg(u_int rdomain); int kr_nexthop_add(u_int32_t, struct bgpd_addr *, struct bgpd_config *); void kr_nexthop_delete(u_int32_t, struct bgpd_addr *, diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c index 5907f0cef67..bdffe63d7a2 100644 --- a/usr.sbin/bgpd/kroute.c +++ b/usr.sbin/bgpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.220 2018/07/12 21:45:37 benno Exp $ */ +/* $OpenBSD: kroute.c,v 1.221 2018/07/14 12:32:35 benno Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -135,8 +135,8 @@ void knexthop_clear(struct ktable *); struct kif_node *kif_find(int); int kif_insert(struct kif_node *); -int kif_remove(struct kif_node *); -void kif_clear(void); +int kif_remove(struct kif_node *, u_int); +void kif_clear(u_int); int kif_kr_insert(struct kroute_node *); int kif_kr_remove(struct kroute_node *); @@ -161,14 +161,14 @@ u_int8_t prefixlen_classful(in_addr_t); u_int8_t mask2prefixlen(in_addr_t); u_int8_t mask2prefixlen6(struct sockaddr_in6 *); void get_rtaddrs(int, struct sockaddr *, struct sockaddr **); -void if_change(u_short, int, struct if_data *); -void if_announce(void *); +void if_change(u_short, int, struct if_data *, u_int); +void if_announce(void *, u_int); int send_rtmsg(int, int, struct ktable *, struct kroute *, u_int8_t); int send_rt6msg(int, int, struct ktable *, struct kroute6 *, u_int8_t); -int dispatch_rtmsg(void); +int dispatch_rtmsg(u_int); int fetchtable(struct ktable *, u_int8_t); int fetchifs(int); int dispatch_rtmsg_addr(struct rt_msghdr *, @@ -759,13 +759,13 @@ krVPN4_delete(struct ktable *kt, struct kroute_full *kl, u_int8_t fib_prio) } void -kr_shutdown(u_int8_t fib_prio) +kr_shutdown(u_int8_t fib_prio, u_int rdomain) { u_int i; for (i = krt_size; i > 0; i--) ktable_free(i - 1, fib_prio); - kif_clear(); + kif_clear(rdomain); } void @@ -870,9 +870,9 @@ kr_fib_update_prio_all(u_int8_t fib_prio) } int -kr_dispatch_msg(void) +kr_dispatch_msg(u_int rdomain) { - return (dispatch_rtmsg()); + return (dispatch_rtmsg(rdomain)); } int @@ -1923,7 +1923,7 @@ kif_insert(struct kif_node *kif) } int -kif_remove(struct kif_node *kif) +kif_remove(struct kif_node *kif, u_int rdomain) { struct ktable *kt; struct kif_kr *kkr; @@ -1934,7 +1934,7 @@ kif_remove(struct kif_node *kif) return (-1); } - if ((kt = ktable_get(/* XXX */ 0)) == NULL) + if ((kt = ktable_get(rdomain)) == NULL) goto done; while ((kkr = LIST_FIRST(&kif->kroute_l)) != NULL) { @@ -1956,12 +1956,12 @@ done: } void -kif_clear(void) +kif_clear(u_int rdomain) { struct kif_node *kif; while ((kif = RB_MIN(kif_tree, &kit)) != NULL) - kif_remove(kif); + kif_remove(kif, rdomain); } int @@ -2474,7 +2474,8 @@ get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) } void -if_change(u_short ifindex, int flags, struct if_data *ifd) +if_change(u_short ifindex, int flags, struct if_data *ifd, + u_int rdomain) { struct ktable *kt; struct kif_node *kif; @@ -2488,6 +2489,9 @@ if_change(u_short ifindex, int flags, struct if_data *ifd) return; } + log_info("%s: ifindex %u, ifi_rdomain %u", __func__, ifindex, + ifd->ifi_rdomain); + kif->k.flags = flags; kif->k.link_state = ifd->ifi_link_state; kif->k.if_type = ifd->ifi_type; @@ -2501,7 +2505,7 @@ if_change(u_short ifindex, int flags, struct if_data *ifd) kif->k.nh_reachable = reachable; - kt = ktable_get(/* XXX */ 0); + kt = ktable_get(rdomain); LIST_FOREACH(kkr, &kif->kroute_l, entry) { if (reachable) @@ -2528,7 +2532,7 @@ if_change(u_short ifindex, int flags, struct if_data *ifd) } void -if_announce(void *msg) +if_announce(void *msg, u_int rdomain) { struct if_announcemsghdr *ifan; struct kif_node *kif; @@ -2548,7 +2552,7 @@ if_announce(void *msg) break; case IFAN_DEPARTURE: kif = kif_find(ifan->ifan_index); - kif_remove(kif); + kif_remove(kif, rdomain); break; } } @@ -3081,7 +3085,7 @@ fetchifs(int ifindex) } int -dispatch_rtmsg(void) +dispatch_rtmsg(u_int rdomain) { char buf[RT_BUF_SIZE]; ssize_t n; @@ -3108,7 +3112,7 @@ dispatch_rtmsg(void) rtm = (struct rt_msghdr *)next; if (lim < next + sizeof(u_short) || lim < next + rtm->rtm_msglen) - fatalx("dispatch_rtmsg: partial rtm in buffer"); + fatalx("%s: partial rtm in buffer", __func__); if (rtm->rtm_version != RTM_VERSION) continue; @@ -3137,10 +3141,10 @@ dispatch_rtmsg(void) case RTM_IFINFO: memcpy(&ifm, next, sizeof(ifm)); if_change(ifm.ifm_index, ifm.ifm_flags, - &ifm.ifm_data); + &ifm.ifm_data, rdomain); break; case RTM_IFANNOUNCE: - if_announce(next); + if_announce(next, rdomain); break; default: /* ignore for now */ |