@@ -0,0 +1,3 @@
+# Generated config based on /usr/src/iproute2-3.2.0/include
+TC_CONFIG_XT_OLD_H:=y
+IPT_LIB_DIR:=/lib/xtables
@@ -144,8 +144,10 @@ enum {
#define IFLA_MAX (__IFLA_MAX - 1)
/* backwards compatibility for userspace */
+#ifndef __KERNEL__
#define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
#define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
+#endif
enum {
IFLA_INET_UNSPEC,
@@ -250,6 +252,9 @@ struct ifla_vlan_qos_mapping {
enum {
IFLA_MACVLAN_UNSPEC,
IFLA_MACVLAN_MODE,
+ IFLA_MACVLAN_MACADDR_MODE,
+ IFLA_MACVLAN_MACADDR,
+ IFLA_MACVLAN_MACADDR_DATA,
__IFLA_MACVLAN_MAX,
};
@@ -260,6 +265,13 @@ enum macvlan_mode {
MACVLAN_MODE_VEPA = 2, /* talk to other ports through ext bridge */
MACVLAN_MODE_BRIDGE = 4, /* talk to bridge ports directly */
MACVLAN_MODE_PASSTHRU = 8,/* take over the underlying device */
+ MACVLAN_MODE_SOURCE = 16,/* use source MAC address list to assign */
+};
+
+enum macvlan_macaddr_mode {
+ MACVLAN_MACADDR_ADD,
+ MACVLAN_MACADDR_DEL,
+ MACVLAN_MACADDR_FLUSH,
};
/* SR-IOV virtual function management section */
@@ -22,15 +22,16 @@
static void explain(void)
{
- fprintf(stderr,
- "Usage: ... macvlan mode { private | vepa | bridge | passthru }\n"
- );
+ fprintf(stderr, "Usage: ... macvlan mode MODE MODE_OPTS\n"
+ "MODE: private | vepa | bridge | passthru | source\n"
+ "MODE_OPTS: for mode \"source\":\n"
+ "\tmacaddr { add <macaddr> | del <macaddr> | flush }\n");
}
static int mode_arg(void)
{
fprintf(stderr, "Error: argument of \"mode\" must be \"private\", "
- "\"vepa\", \"bridge\" or \"passthru\" \n");
+ "\"vepa\", \"bridge\", \"passthru\" or \"source\"\n");
return -1;
}
@@ -50,10 +51,40 @@ static int macvlan_parse_opt(struct link
mode = MACVLAN_MODE_BRIDGE;
else if (strcmp(*argv, "passthru") == 0)
mode = MACVLAN_MODE_PASSTHRU;
+ else if (strcmp(*argv, "source") == 0)
+ mode = MACVLAN_MODE_SOURCE;
else
return mode_arg();
addattr32(n, 1024, IFLA_MACVLAN_MODE, mode);
+ } else if (matches(*argv, "macaddr") == 0) {
+ int len;
+ __u32 mac_mode = 0;
+ char abuf[32];
+
+ NEXT_ARG();
+
+ if (strcmp(*argv, "add") == 0) {
+ mac_mode = MACVLAN_MACADDR_ADD;
+ } else if (strcmp(*argv, "del") == 0) {
+ mac_mode = MACVLAN_MACADDR_DEL;
+ } else if (strcmp(*argv, "flush") == 0) {
+ mac_mode = MACVLAN_MACADDR_FLUSH;
+ } else {
+ explain();
+ return -1;
+ }
+ addattr32(n, 1024, IFLA_MACVLAN_MACADDR_MODE, mac_mode);
+
+ if (mac_mode != MACVLAN_MACADDR_FLUSH) {
+ NEXT_ARG();
+
+ len = ll_addr_a2n(abuf, sizeof(abuf), *argv);
+ if (len < 0)
+ return -1;
+ addattr_l(n, 1024, IFLA_MACVLAN_MACADDR, abuf,
+ len);
+ }
} else if (matches(*argv, "help") == 0) {
explain();
return -1;
@@ -85,6 +116,7 @@ static void macvlan_print_opt(struct lin
: mode == MACVLAN_MODE_VEPA ? "vepa"
: mode == MACVLAN_MODE_BRIDGE ? "bridge"
: mode == MACVLAN_MODE_PASSTHRU ? "passthru"
+ : mode == MACVLAN_MODE_SOURCE ? "source"
: "unknown");
}