summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Fondras <denis@cvs.openbsd.org>2024-08-17 09:52:12 +0000
committerDenis Fondras <denis@cvs.openbsd.org>2024-08-17 09:52:12 +0000
commit9ea5f7eafd8333a3a97080eff9cba3c4386b89f0 (patch)
tree8117ea9fe164164fcdf97f2cf8e83ad604dad23b
parent75ae433fb02a9b69039d777fc041a6b902a81db3 (diff)
Allow PPP interface to run in an rdomain and get a default route installed in the same routing domain
Input and OK claudio@
-rw-r--r--sys/net/ppp_tty.c3
-rw-r--r--usr.sbin/pppd/sys-bsd.c20
2 files changed, 21 insertions, 2 deletions
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
@@ -1032,6 +1032,23 @@ cifaddr(int u, u_int32_t o, u_int32_t h)
}
/*
+ * 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.
*/
int
@@ -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);