Hello, Patches 11 & 12.
# HG changeset patch # User MJP # Date 1452862954 -3600 # Fri Jan 15 14:02:34 2016 +0100 # Node ID 5c95b08cdd4fa9db47ced3b8b1a331dbdab41ec6 # Parent 842c1c22848e171f174cc45ba7b961883fc3c184 Feature: Configure interface with the specified rdomain. diff -r 842c1c22848e -r 5c95b08cdd4f usr.sbin/npppd/npppd/npppd_iface.c --- usr.sbin/npppd/npppd/npppd_iface.c Fri Jan 15 14:02:34 2016 +0100 +++ usr.sbin/npppd/npppd/npppd_iface.c Fri Jan 15 14:02:34 2016 +0100 @@ -87,6 +87,7 @@ #endif static void npppd_iface_network_input(npppd_iface *, u_char *, int); +static int npppd_iface_setup_rdomain(npppd_iface *); static int npppd_iface_setup_ip(npppd_iface *); static void npppd_iface_io_event_handler (int, short, void *); static int npppd_iface_log (npppd_iface *, int, const char *, ...) @@ -111,15 +112,28 @@ _this->using_pppx = iface->is_pppx; _this->set_ip4addr = 1; _this->ip4addr = iface->ip4addr; + _this->rdomain = iface->rdomain; _this->ipcpconf = iface->ipcpconf; _this->devf = -1; _this->initialized = 1; } static int +npppd_iface_setup_rdomain(npppd_iface *_this) +{ + if (priv_set_if_rdomain(_this->ifname, _this->rdomain) != 0) { + npppd_iface_log(_this, LOG_ERR, + "setting rdomain on %s failed: %m", _this->ifname); + return 1; + } + + return 0; +} + +static int npppd_iface_setup_ip(npppd_iface *_this) { - int sock, if_flags, changed; + int sock, if_flags, changed, old_rdomain; struct in_addr gw, assigned; struct sockaddr_in *sin0; struct ifreq ifr; @@ -152,6 +166,17 @@ if (assigned.s_addr != _this->ip4addr.s_addr) changed = 1; + /* get rdomain which was assigned to interface */ + if (priv_get_if_rdomain(_this->ifname, &old_rdomain) != 0) { + log_printf(LOG_ERR, "ioctl(,SIOCGIFRDOMAIN) failed: %m", __func__); + goto fail; + } + if (_this->rdomain != old_rdomain) { + changed = 1; + if (npppd_iface_setup_rdomain(_this) != 0) + goto fail; + } + if (priv_get_if_flags(_this->ifname, &if_flags) != 0) { npppd_iface_log(_this, LOG_ERR, "ioctl(,SIOCGIFFLAGS) failed: %m"); @@ -195,7 +220,7 @@ /* erase old route */ if (assigned.s_addr != 0) { gw.s_addr = htonl(INADDR_LOOPBACK); - in_host_route_delete(&assigned, &gw, _this->rdomain); + in_host_route_delete(&assigned, &gw, old_rdomain); } assigned.s_addr = _this->ip4addr.s_addr; @@ -252,9 +277,15 @@ _this->ipcpconf = iface->ipcpconf; backup = _this->ip4addr; _this->ip4addr = iface->ip4addr; + _this->rdomain = iface->rdomain; - if (_this->using_pppx) + if (_this->using_pppx) { + /* ifconfig tun1 rdomain X */ + if (npppd_iface_setup_rdomain(_this) != 0) + return 1; + return 0; + } if ((rval = npppd_iface_setup_ip(_this)) != 0) return rval; @@ -312,6 +343,9 @@ if (_this->using_pppx == 0) { if (npppd_iface_setup_ip(_this) != 0) goto fail; + } else { + if (npppd_iface_setup_rdomain(_this) != 0) + goto fail; } #ifdef USE_NPPPD_PIPEX # HG changeset patch # User MJP # Date 1452862954 -3600 # Fri Jan 15 14:02:34 2016 +0100 # Node ID 51e9ae42d8660dcf396d3781b01e70e837f57107 # Parent 5c95b08cdd4fa9db47ced3b8b1a331dbdab41ec6 Documentation: Update the manual page (interface [rdomain]). diff -r 5c95b08cdd4f -r 51e9ae42d866 usr.sbin/npppd/npppd/npppd.conf.5 --- usr.sbin/npppd/npppd/npppd.conf.5 Fri Jan 15 14:02:34 2016 +0100 +++ usr.sbin/npppd/npppd/npppd.conf.5 Fri Jan 15 14:02:34 2016 +0100 @@ -520,7 +520,7 @@ .Ic interface setting is described below: .Pp -.Ic interface Ar ifname Ic address Ar address Ic ipcp Ar ipcp +.Ic interface Ar ifname Ic address Ar address Ic ipcp Ar ipcp Op Ic rdomain Ar rdomainid .Pp Use .Xr tun 4