-/* $OpenBSD: kroute.c,v 1.292 2022/08/17 15:15:26 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.293 2022/08/18 12:14:00 claudio Exp $ */
/*
* Copyright (c) 2022 Claudio Jeker <claudio@openbsd.org>
void if_change(u_short, int, struct if_data *);
void if_announce(void *);
-int send_rtmsg(int, int, struct ktable *, struct kroute_full *);
+int send_rtmsg(int, struct ktable *, struct kroute_full *);
int dispatch_rtmsg(void);
int fetchtable(struct ktable *);
int fetchifs(int);
else
kr->flags &= ~F_REJECT;
- if (send_rtmsg(kr_state.fd, RTM_CHANGE, kt, kf))
+ if (send_rtmsg(RTM_CHANGE, kt, kf))
kr->flags |= F_BGPD_INSERTED;
}
else
kr6->flags &= ~F_REJECT;
- if (send_rtmsg(kr_state.fd, RTM_CHANGE, kt, kf))
+ if (send_rtmsg(RTM_CHANGE, kt, kf))
kr6->flags |= F_BGPD_INSERTED;
}
else
kr->flags &= ~F_REJECT;
- if (send_rtmsg(kr_state.fd, RTM_CHANGE, kt, kf))
+ if (send_rtmsg(RTM_CHANGE, kt, kf))
kr->flags |= F_BGPD_INSERTED;
}
else
kr6->flags &= ~F_REJECT;
- if (send_rtmsg(kr_state.fd, RTM_CHANGE, kt, kf))
+ if (send_rtmsg(RTM_CHANGE, kt, kf))
kr6->flags |= F_BGPD_INSERTED;
}
RB_FOREACH(kr, kroute_tree, &kt->krt)
if (kr->flags & F_BGPD) {
- if (send_rtmsg(kr_state.fd, RTM_ADD, kt,
- kr_tofull(kr)))
+ if (send_rtmsg(RTM_ADD, kt, kr_tofull(kr)))
kr->flags |= F_BGPD_INSERTED;
}
RB_FOREACH(kr6, kroute6_tree, &kt->krt6)
if (kr6->flags & F_BGPD) {
- if (send_rtmsg(kr_state.fd, RTM_ADD, kt,
- kr6_tofull(kr6)))
+ if (send_rtmsg(RTM_ADD, kt, kr6_tofull(kr6)))
kr6->flags |= F_BGPD_INSERTED;
}
log_info("kernel routing table %u (%s) coupled", kt->rtableid,
RB_FOREACH(kr, kroute_tree, &kt->krt)
if ((kr->flags & F_BGPD_INSERTED)) {
- if (send_rtmsg(kr_state.fd, RTM_DELETE, kt,
- kr_tofull(kr)))
+ if (send_rtmsg(RTM_DELETE, kt, kr_tofull(kr)))
kr->flags &= ~F_BGPD_INSERTED;
}
RB_FOREACH(kr6, kroute6_tree, &kt->krt6)
if ((kr6->flags & F_BGPD_INSERTED)) {
- if (send_rtmsg(kr_state.fd, RTM_DELETE, kt,
- kr6_tofull(kr6)))
+ if (send_rtmsg(RTM_DELETE, kt, kr6_tofull(kr6)))
kr6->flags &= ~F_BGPD_INSERTED;
}
}
if (kf->flags & F_BGPD)
- if (send_rtmsg(kr_state.fd, RTM_ADD, kt, kf))
+ if (send_rtmsg(RTM_ADD, kt, kf))
kr->flags |= F_BGPD_INSERTED;
break;
case AID_INET6:
}
if (kf->flags & F_BGPD)
- if (send_rtmsg(kr_state.fd, RTM_ADD, kt, kf))
+ if (send_rtmsg(RTM_ADD, kt, kf))
kr6->flags |= F_BGPD_INSERTED;
break;
}
return (multipath + 1);
if (kf->flags & F_BGPD_INSERTED)
- send_rtmsg(kr_state.fd, RTM_DELETE, kt, kf);
+ send_rtmsg(RTM_DELETE, kt, kf);
/* remove only once all multipath routes are gone */
if (!(kf->flags & F_BGPD) && !multipath)
#define satosin6(sa) ((struct sockaddr_in6 *)(sa))
int
-send_rtmsg(int fd, int action, struct ktable *kt, struct kroute_full *kf)
+send_rtmsg(int action, struct ktable *kt, struct kroute_full *kf)
{
struct iovec iov[7];
struct rt_msghdr hdr;
}
retry:
- if (writev(fd, iov, iovcnt) == -1) {
+ if (writev(kr_state.fd, iov, iovcnt) == -1) {
if (errno == ESRCH) {
if (hdr.rtm_type == RTM_CHANGE) {
hdr.rtm_type = RTM_ADD;
continue;
if (kf.priority == RTP_MINE)
- send_rtmsg(kr_state.fd, RTM_DELETE, kt, &kf);
+ send_rtmsg(RTM_DELETE, kt, &kf);
else
kroute_insert(kt, &kf);
}