diff options
author | Andrey V. Elsukov <ae@FreeBSD.org> | 2015-05-12 07:37:27 +0000 |
---|---|---|
committer | Andrey V. Elsukov <ae@FreeBSD.org> | 2015-05-12 07:37:27 +0000 |
commit | eccfe69a5c486bfc7d7877d66d98e928c2191351 (patch) | |
tree | f1c878482abb06e942d871316149ceffb7479b15 /sbin/ifconfig/iffib.c | |
parent | 0a23444a57b962959c35d5f9035105f0dc4e1bcd (diff) | |
download | src-eccfe69a5c486bfc7d7877d66d98e928c2191351.tar.gz src-eccfe69a5c486bfc7d7877d66d98e928c2191351.zip |
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
No objection from: #network
MFC after: 2 weeks
Sponsored by: Yandex LLC
Notes
Notes:
svn path=/head/; revision=282809
Diffstat (limited to 'sbin/ifconfig/iffib.c')
-rw-r--r-- | sbin/ifconfig/iffib.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/sbin/ifconfig/iffib.c b/sbin/ifconfig/iffib.c index f3498b42e486..07ded3cbb24f 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 = { |