|
|
049c96 |
From 65d44f53fc70fa57b76a4eb5dadb1eeda5996924 Mon Sep 17 00:00:00 2001
|
|
|
049c96 |
From: Phil Sutter <psutter@redhat.com>
|
|
|
049c96 |
Date: Fri, 4 Mar 2016 17:46:07 +0100
|
|
|
049c96 |
Subject: [PATCH] ip: macvlan: support MACVLAN_FLAG_NOPROMISC flag
|
|
|
049c96 |
|
|
|
049c96 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1013584
|
|
|
049c96 |
Upstream Status: iproute2.git commit 3cf8ba596026b
|
|
|
049c96 |
|
|
|
049c96 |
commit 3cf8ba596026b61f58e674fa28f3a310597e8d36
|
|
|
049c96 |
Author: Phil Sutter <phil@nwl.cc>
|
|
|
049c96 |
Date: Fri Sep 25 14:09:50 2015 +0200
|
|
|
049c96 |
|
|
|
049c96 |
ip: macvlan: support MACVLAN_FLAG_NOPROMISC flag
|
|
|
049c96 |
|
|
|
049c96 |
This flag is allowed for devices in passthru mode to prevent forcing the
|
|
|
049c96 |
underlying interface into promiscuous mode.
|
|
|
049c96 |
|
|
|
049c96 |
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
|
|
049c96 |
---
|
|
|
049c96 |
ip/iplink_macvlan.c | 30 +++++++++++++++++++++++++++---
|
|
|
049c96 |
1 file changed, 27 insertions(+), 3 deletions(-)
|
|
|
049c96 |
|
|
|
049c96 |
diff --git a/ip/iplink_macvlan.c b/ip/iplink_macvlan.c
|
|
|
049c96 |
index b972d0e..f2677e1 100644
|
|
|
049c96 |
--- a/ip/iplink_macvlan.c
|
|
|
049c96 |
+++ b/ip/iplink_macvlan.c
|
|
|
049c96 |
@@ -29,7 +29,7 @@
|
|
|
049c96 |
static void print_explain(struct link_util *lu, FILE *f)
|
|
|
049c96 |
{
|
|
|
049c96 |
fprintf(f,
|
|
|
049c96 |
- "Usage: ... %s mode { private | vepa | bridge | passthru }\n",
|
|
|
049c96 |
+ "Usage: ... %s mode { private | vepa | bridge | passthru [nopromisc] }\n",
|
|
|
049c96 |
lu->id
|
|
|
049c96 |
);
|
|
|
049c96 |
}
|
|
|
049c96 |
@@ -49,9 +49,11 @@ static int mode_arg(const char *arg)
|
|
|
049c96 |
static int macvlan_parse_opt(struct link_util *lu, int argc, char **argv,
|
|
|
049c96 |
struct nlmsghdr *n)
|
|
|
049c96 |
{
|
|
|
049c96 |
+ __u32 mode = 0;
|
|
|
049c96 |
+ __u16 flags = 0;
|
|
|
049c96 |
+
|
|
|
049c96 |
while (argc > 0) {
|
|
|
049c96 |
if (matches(*argv, "mode") == 0) {
|
|
|
049c96 |
- __u32 mode = 0;
|
|
|
049c96 |
NEXT_ARG();
|
|
|
049c96 |
|
|
|
049c96 |
if (strcmp(*argv, "private") == 0)
|
|
|
049c96 |
@@ -64,7 +66,8 @@ static int macvlan_parse_opt(struct link_util *lu, int argc, char **argv,
|
|
|
049c96 |
mode = MACVLAN_MODE_PASSTHRU;
|
|
|
049c96 |
else
|
|
|
049c96 |
return mode_arg(*argv);
|
|
|
049c96 |
- addattr32(n, 1024, IFLA_MACVLAN_MODE, mode);
|
|
|
049c96 |
+ } else if (matches(*argv, "nopromisc") == 0) {
|
|
|
049c96 |
+ flags |= MACVLAN_FLAG_NOPROMISC;
|
|
|
049c96 |
} else if (matches(*argv, "help") == 0) {
|
|
|
049c96 |
explain(lu);
|
|
|
049c96 |
return -1;
|
|
|
049c96 |
@@ -76,12 +79,25 @@ static int macvlan_parse_opt(struct link_util *lu, int argc, char **argv,
|
|
|
049c96 |
argc--, argv++;
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
+ if (mode)
|
|
|
049c96 |
+ addattr32(n, 1024, IFLA_MACVLAN_MODE, mode);
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (flags) {
|
|
|
049c96 |
+ if (flags & MACVLAN_FLAG_NOPROMISC &&
|
|
|
049c96 |
+ mode != MACVLAN_MODE_PASSTHRU) {
|
|
|
049c96 |
+ pfx_err(lu, "nopromisc flag only valid in passthru mode");
|
|
|
049c96 |
+ explain(lu);
|
|
|
049c96 |
+ return -1;
|
|
|
049c96 |
+ }
|
|
|
049c96 |
+ addattr16(n, 1024, IFLA_MACVLAN_FLAGS, flags);
|
|
|
049c96 |
+ }
|
|
|
049c96 |
return 0;
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
static void macvlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
|
|
049c96 |
{
|
|
|
049c96 |
__u32 mode;
|
|
|
049c96 |
+ __u16 flags;
|
|
|
049c96 |
|
|
|
049c96 |
if (!tb)
|
|
|
049c96 |
return;
|
|
|
049c96 |
@@ -97,6 +113,14 @@ static void macvlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]
|
|
|
049c96 |
: mode == MACVLAN_MODE_BRIDGE ? "bridge"
|
|
|
049c96 |
: mode == MACVLAN_MODE_PASSTHRU ? "passthru"
|
|
|
049c96 |
: "unknown");
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (!tb[IFLA_MACVLAN_FLAGS] ||
|
|
|
049c96 |
+ RTA_PAYLOAD(tb[IFLA_MACVLAN_FLAGS]) < sizeof(__u16))
|
|
|
049c96 |
+ return;
|
|
|
049c96 |
+
|
|
|
049c96 |
+ flags = rta_getattr_u16(tb[IFLA_MACVLAN_FLAGS]);
|
|
|
049c96 |
+ if (flags & MACVLAN_FLAG_NOPROMISC)
|
|
|
049c96 |
+ fprintf(f, "nopromisc ");
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
static void macvlan_print_help(struct link_util *lu, int argc, char **argv,
|
|
|
049c96 |
--
|
|
|
049c96 |
1.8.3.1
|
|
|
049c96 |
|