Source mode for macvlan interface
Subsystems (2)
PATCH v4 1/1 Source mode for macvlan interface
In reply to a message not in the archiveFrom: Stefan Gula <[email protected]>
Adjusting iproute2 utility to support new macvlan link type mode called "source". Example of commands that can be applied:
ip link add link eth0 name macvlan0 type macvlan mode source ip link set link macvlan0 type macvlan macaddr add 00:11:11:11:11:11 ip link set link macvlan0 type macvlan macaddr del 00:11:11:11:11:11 ip link set link macvlan0 type macvlan macaddr flush
---
V4 changes:
- added documentation to manual
- added ability to list list of the allowed mac address by using "ip -d link"
- added devdump ops to be able to get extra dynamic, link type based info from kernel using DEVDUMP command
- as rtnetlink patch is still under discussion, so please treat this one as only example how it can work
include/linux/if_link.h +13 -0
@@ -250,6 +250,10 @@ 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_MACADDR_COUNT , __IFLA_MACVLAN_MAX, };
@@ -260,8 +264,17 @@ 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 , +}; + +#define MACVLAN_DUMP_PAGE_COUNT 10 +/* SR-IOV virtual function management section */ enum {
include/linux/rtnetlink.h +2 -0
@@ -120,6 +120,8 @@ enum { RTM_SETDCB,#define RTM_SETDCB RTM_SETDCB + RTM_DEVDUMP = 80, +#define RTM_DEVDUMP RTM_DEVDUMP __RTM_MAX,#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) };
ip/ip_common.h +2 -0
@@ -63,6 +63,8 @@ struct link_util struct rtattr *[]);void (*print_xstats)(struct link_util *,FILE *,struct rtattr *); +void (*print_devdump)(char *,FILE *, +struct rtattr **); };struct link_util *get_link_kind (const char *kind);
ip/ipaddress.c +5 -3
@@ -157,7 +157,7 @@ static void print_queuelen(FILE *f, strufprintf (f,"qlen %d" , qlen); } -static void print_linktype (FILE *fp,struct rtattr *tb) +static void print_linktype (FILE *fp,struct rtattr *tb,char *dev) {struct rtattr *linkinfo[IFLA_INFO_MAX +1 ];struct link_util *lu;
@@ -185,7 +185,8 @@ static void print_linktype(FILE *fp, str data = attr; } lu->print_opt (lu, fp, data); - +if (lu->print_devdump) + lu->print_devdump (dev, fp, data);if (linkinfo[IFLA_INFO_XSTATS ] && show_stats && lu->print_xstats) lu->print_xstats (lu, fp, linkinfo[IFLA_INFO_XSTATS ]);
@@ -336,7 +337,8 @@ int print_linkinfo(const struct sockaddr }if (do_link && tb[IFLA_LINKINFO ] && show_details) -print_linktype (fp, tb[IFLA_LINKINFO ]); +print_linktype (fp, tb[IFLA_LINKINFO ], +RTA_DATA (tb[IFLA_IFNAME ]));if (do_link && tb[IFLA_IFALIAS ]) fprintf(fp,"\n alias %s",
ip/iplink_macvlan.c +117 -4
161 lines not on this page · raw message
man/man8/ip-link.8 +59 -1
80 lines not on this page · raw message