From: denis Date: Sat, 17 Aug 2024 09:52:11 +0000 (+0000) Subject: Allow PPP interface to run in an rdomain and get a default route installed in the... X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=895cab01f2e44747710971313dbbef968a4d19a2;p=openbsd Allow PPP interface to run in an rdomain and get a default route installed in the same routing domain Input and OK claudio@ --- diff --git a/sys/net/ppp_tty.c b/sys/net/ppp_tty.c index 6c8d82c2e09..ce2131c2561 100644 --- a/sys/net/ppp_tty.c +++ b/sys/net/ppp_tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ppp_tty.c,v 1.54 2022/01/02 22:36:04 jsg Exp $ */ +/* $OpenBSD: ppp_tty.c,v 1.55 2024/08/17 09:52:11 denis Exp $ */ /* $NetBSD: ppp_tty.c,v 1.12 1997/03/24 21:23:10 christos Exp $ */ /* @@ -371,6 +371,7 @@ pppwrite(struct tty *tp, struct uio *uio, int flag) bcopy(mtod(m0, u_char *), dst.sa_data, PPP_HDRLEN); m0->m_data += PPP_HDRLEN; m0->m_len -= PPP_HDRLEN; + m0->m_pkthdr.ph_rtableid = sc->sc_if.if_rdomain; return sc->sc_if.if_output(&sc->sc_if, m0, &dst, NULL); } diff --git a/usr.sbin/pppd/sys-bsd.c b/usr.sbin/pppd/sys-bsd.c index 25e1e336783..033e5772edf 100644 --- a/usr.sbin/pppd/sys-bsd.c +++ b/usr.sbin/pppd/sys-bsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys-bsd.c,v 1.35 2024/08/10 05:32:28 jsg Exp $ */ +/* $OpenBSD: sys-bsd.c,v 1.36 2024/08/17 09:52:11 denis Exp $ */ /* * sys-bsd.c - System-dependent procedures for setting up @@ -1031,6 +1031,23 @@ cifaddr(int u, u_int32_t o, u_int32_t h) return 1; } +/* + * getrtableid - return routing table id of ppp interface + */ +int +getrtableid(void) +{ + struct ifreq ifr; + int tableid = 0; + + memset(&ifr, 0, sizeof(ifr)); + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + if (ioctl(sockfd, SIOCGIFRDOMAIN, (caddr_t) &ifr) == 0) + tableid = ifr.ifr_rdomainid; + + return tableid; +} + /* * sifdefaultroute - assign a default route through the address given. */ @@ -1073,6 +1090,7 @@ dodefaultroute(u_int32_t g, int cmd) rtmsg.hdr.rtm_type = cmd == 's'? RTM_ADD: RTM_DELETE; rtmsg.hdr.rtm_flags = RTF_UP | RTF_GATEWAY; rtmsg.hdr.rtm_version = RTM_VERSION; + rtmsg.hdr.rtm_tableid = getrtableid(); rtmsg.hdr.rtm_seq = ++rtm_seq; rtmsg.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK; rtmsg.dst.sin_len = sizeof(rtmsg.dst);