Index | Thread | Search

From:
Denis Fondras <denis@openbsd.org>
Subject:
pppd(8): add support for rdomain
To:
tech@openbsd.org
Date:
Sat, 29 Jun 2024 17:54:28 +0200

Download raw body.

Thread
With this diff, we can run the PPP interface in an rdomain and get a default
route installed.

However, I still have a warning in the logs : "ppp0: trying to send packet on wrong
domain. if 5 vs. mbuf 0, AF 0"

Index: sys-bsd.c
===================================================================
RCS file: /cvs/src/usr.sbin/pppd/sys-bsd.c,v
diff -u -p -r1.33 sys-bsd.c
--- sys-bsd.c	19 Feb 2024 16:39:03 -0000	1.33
+++ sys-bsd.c	29 Jun 2024 15:42:37 -0000
@@ -118,6 +118,7 @@ static int initdisc = -1;	/* Initial TTY
 static int initfdflags = -1;	/* Initial file descriptor flags for ppp_fd */
 static int ppp_fd = -1;		/* fd which is set to PPP discipline */
 static int rtm_seq;
+static int rtableid;

 static int restore_term;	/* 1 => we've munged the terminal */
 static struct termios inittermios; /* Initial TTY termios */
@@ -218,7 +219,9 @@ ppp_available()
 	return 1;		/* can't tell */

     strlcpy(ifr.ifr_name, "ppp0", sizeof(ifr.ifr_name));
-    ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) == 0;
+    ok = ioctl(s, SIOCGIFRDOMAIN, (caddr_t) &ifr) == 0;
+    if (ok)
+	rtableid = ifr.ifr_rdomainid;
     close(s);

     no_ppp_msg = "\
@@ -1115,6 +1118,7 @@ dodefaultroute(g, cmd)
     memset(&rtmsg, 0, sizeof(rtmsg));
     rtmsg.hdr.rtm_type = cmd == 's'? RTM_ADD: RTM_DELETE;
     rtmsg.hdr.rtm_flags = RTF_UP | RTF_GATEWAY;
+    rtmsg.hdr.rtm_tableid = rtableid;
     rtmsg.hdr.rtm_version = RTM_VERSION;
     rtmsg.hdr.rtm_seq = ++rtm_seq;
     rtmsg.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK;