History

macvlan: add source mode

This patch adds a new mode of operation to macvlan, called "source". It allows one to set a list of allowed mac address, which is used to match against source mac address from received frames on underlying interface. This enables creating mac based VLAN associations, instead of standard port or tag based. The feature is useful to deploy 802.1x mac based behavior, where drivers of underlying interfaces doesn't allows that. Configuration is done through the netlink interface using e.g.: ip link add link eth0 name macvlan0 type macvlan mode source ip link add link eth0 name macvlan1 type macvlan mode source ip link set link dev macvlan0 type macvlan macaddr add 00:11:11:11:11:11 ip link set link dev macvlan0 type macvlan macaddr add 00:22:22:22:22:22 ip link set link dev macvlan0 type macvlan macaddr add 00:33:33:33:33:33 ip link set link dev macvlan1 type macvlan macaddr add 00:33:33:33:33:33 ip link set link dev macvlan1 type macvlan macaddr add 00:44:44:44:44:44 This allows clients with MAC addresses 00:11:11:11:11:11, 00:22:22:22:22:22 to be part of only VLAN associated with macvlan0 interface. Clients with MAC addresses 00:44:44:44:44:44 with only VLAN associated with macvlan1 interface. And client with MAC address 00:33:33:33:33:33 to be associated with both VLANs. Based on work of Stefan Gula <steweg@gmail.com> v8: last version of Stefan Gula for Kernel 3.2.1 v9: rework onto linux-next 2014-03-12 by Michael Braun add MACADDR_SET command, enable to configure mac for source mode while creating interface v10: - reduce indention level - rename source_list to source_entry - use aligned 64bit ether address - use hash_64 instead of addr[5] v11: - rebase for 3.14 / linux-next 20.04.2014 v12 - rebase for linux-next 2014-09-25

Michael Braun committed 12 years ago

Commit 79cf79a1 parent 85224843 files · +314 −3Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/if_link.h+12−0
@@ -303,6 +303,10 @@ enum { · 302 unmodified lines
303303 IFLA_MACVLAN_UNSPEC,
304304 IFLA_MACVLAN_MODE,
305305 IFLA_MACVLAN_FLAGS,
306+ IFLA_MACVLAN_MACADDR_MODE,
307+ IFLA_MACVLAN_MACADDR,
308+ IFLA_MACVLAN_MACADDR_DATA,
309+ IFLA_MACVLAN_MACADDR_COUNT,
306310 __IFLA_MACVLAN_MAX,
307311 };
308312
@@ -313,6 +317,14 @@ enum macvlan_mode { · 4 unmodified lines
313317 MACVLAN_MODE_VEPA = 2, /* talk to other ports through ext bridge */
314318 MACVLAN_MODE_BRIDGE = 4, /* talk to bridge ports directly */
315319 MACVLAN_MODE_PASSTHRU = 8,/* take over the underlying device */
320+ MACVLAN_MODE_SOURCE = 16,/* use source MAC address list to assign */
321+};
322+
323+enum macvlan_macaddr_mode {
324+ MACVLAN_MACADDR_ADD,
325+ MACVLAN_MACADDR_DEL,
326+ MACVLAN_MACADDR_FLUSH,
327+ MACVLAN_MACADDR_SET,
316328 };
317329
318330 #define MACVLAN_FLAG_NOPROMISC 1