summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2015-06-06 13:37:11 +0000
committerae <ae@FreeBSD.org>2015-06-06 13:37:11 +0000
commit49fd76c05c1937d6c5bf27f823249d3605121fe0 (patch)
tree3d06542ff82c49ec0e8aa645752292c78b063d37 /sbin
parentad4eef6e15d2ae1de604f25c34a649a49fab352b (diff)
downloadFreeBSD-src-49fd76c05c1937d6c5bf27f823249d3605121fe0.zip
FreeBSD-src-49fd76c05c1937d6c5bf27f823249d3605121fe0.tar.gz
MFC r282809:
Add new socket ioctls SIOC[SG]TUNFIB to set FIB number of encapsulated packets on tunnel interfaces. Add support of these ioctls to gre(4), gif(4) and me(4) interfaces. For incoming packets M_SETFIB() should use if_fib value from ifnet structure, use proper value in gre(4) and me(4). Differential Revision: https://reviews.freebsd.org/D2462
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ifconfig/ifconfig.88
-rw-r--r--sbin/ifconfig/iffib.c36
2 files changed, 36 insertions, 8 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8
index ec8d9d6..344adc3 100644
--- a/sbin/ifconfig/ifconfig.8
+++ b/sbin/ifconfig/ifconfig.8
@@ -321,6 +321,14 @@ using the
kernel configuration option, or the
.Va net.fibs
tunable.
+.It Cm tunnelfib Ar fib_number
+Specify tunnel FIB.
+A FIB
+.Ar fib_number
+is assigned to all packets encapsulated by tunnel interface, e.g.,
+.Xr gif 4
+and
+.Xr gre 4 .
.It Cm ipdst
This is used to specify an Internet host who is willing to receive
IP packets encapsulating IPX packets bound for a remote network.
diff --git a/sbin/ifconfig/iffib.c b/sbin/ifconfig/iffib.c
index f3498b4..07ded3c 100644
--- a/sbin/ifconfig/iffib.c
+++ b/sbin/ifconfig/iffib.c
@@ -50,15 +50,15 @@ fib_status(int s)
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ if (ioctl(s, SIOCGIFFIB, (caddr_t)&ifr) == 0 &&
+ ifr.ifr_fib != RT_DEFAULT_FIB)
+ printf("\tfib: %u\n", ifr.ifr_fib);
- if (ioctl(s, SIOCGIFFIB, (caddr_t)&ifr) < 0)
- return;
-
- /* Ignore if it is the default. */
- if (ifr.ifr_fib == 0)
- return;
-
- printf("\tfib: %u\n", ifr.ifr_fib);
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ if (ioctl(s, SIOCGTUNFIB, (caddr_t)&ifr) == 0 &&
+ ifr.ifr_fib != RT_DEFAULT_FIB)
+ printf("\ttunnelfib: %u\n", ifr.ifr_fib);
}
static void
@@ -80,8 +80,28 @@ setiffib(const char *val, int dummy __unused, int s,
warn("ioctl (SIOCSIFFIB)");
}
+static void
+settunfib(const char *val, int dummy __unused, int s,
+ const struct afswtch *afp)
+{
+ unsigned long fib;
+ char *ep;
+
+ fib = strtoul(val, &ep, 0);
+ if (*ep != '\0' || fib > UINT_MAX) {
+ warn("fib %s not valid", val);
+ return;
+ }
+
+ strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
+ ifr.ifr_fib = fib;
+ if (ioctl(s, SIOCSTUNFIB, (caddr_t)&ifr) < 0)
+ warn("ioctl (SIOCSTUNFIB)");
+}
+
static struct cmd fib_cmds[] = {
DEF_CMD_ARG("fib", setiffib),
+ DEF_CMD_ARG("tunnelfib", settunfib),
};
static struct afswtch af_fib = {
OpenPOWER on IntegriCloud