diff options
author | Patrick McHardy <kaber@trash.net> | 2007-07-14 21:55:06 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-07-14 21:55:06 -0400 |
commit | b863ceb7ddcea8c55fcf1d7b2ac591d50aa7ed53 (patch) | |
tree | a65d5e4be77666600c0005c5f4c9091df63a3a1b /net | |
parent | 56addd6eeeb4e11f5a0af7093ca078e0f29140e0 (diff) |
[NET]: Add macvlan driver
Add macvlan driver, which allows to create virtual ethernet devices
based on MAC address.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/dev.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 59ec811d2b54..13a0d9f6da54 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -98,6 +98,7 @@ | |||
98 | #include <linux/seq_file.h> | 98 | #include <linux/seq_file.h> |
99 | #include <linux/stat.h> | 99 | #include <linux/stat.h> |
100 | #include <linux/if_bridge.h> | 100 | #include <linux/if_bridge.h> |
101 | #include <linux/if_macvlan.h> | ||
101 | #include <net/dst.h> | 102 | #include <net/dst.h> |
102 | #include <net/pkt_sched.h> | 103 | #include <net/pkt_sched.h> |
103 | #include <net/checksum.h> | 104 | #include <net/checksum.h> |
@@ -1813,6 +1814,28 @@ static inline struct sk_buff *handle_bridge(struct sk_buff *skb, | |||
1813 | #define handle_bridge(skb, pt_prev, ret, orig_dev) (skb) | 1814 | #define handle_bridge(skb, pt_prev, ret, orig_dev) (skb) |
1814 | #endif | 1815 | #endif |
1815 | 1816 | ||
1817 | #if defined(CONFIG_MACVLAN) || defined(CONFIG_MACVLAN_MODULE) | ||
1818 | struct sk_buff *(*macvlan_handle_frame_hook)(struct sk_buff *skb) __read_mostly; | ||
1819 | EXPORT_SYMBOL_GPL(macvlan_handle_frame_hook); | ||
1820 | |||
1821 | static inline struct sk_buff *handle_macvlan(struct sk_buff *skb, | ||
1822 | struct packet_type **pt_prev, | ||
1823 | int *ret, | ||
1824 | struct net_device *orig_dev) | ||
1825 | { | ||
1826 | if (skb->dev->macvlan_port == NULL) | ||
1827 | return skb; | ||
1828 | |||
1829 | if (*pt_prev) { | ||
1830 | *ret = deliver_skb(skb, *pt_prev, orig_dev); | ||
1831 | *pt_prev = NULL; | ||
1832 | } | ||
1833 | return macvlan_handle_frame_hook(skb); | ||
1834 | } | ||
1835 | #else | ||
1836 | #define handle_macvlan(skb, pt_prev, ret, orig_dev) (skb) | ||
1837 | #endif | ||
1838 | |||
1816 | #ifdef CONFIG_NET_CLS_ACT | 1839 | #ifdef CONFIG_NET_CLS_ACT |
1817 | /* TODO: Maybe we should just force sch_ingress to be compiled in | 1840 | /* TODO: Maybe we should just force sch_ingress to be compiled in |
1818 | * when CONFIG_NET_CLS_ACT is? otherwise some useless instructions | 1841 | * when CONFIG_NET_CLS_ACT is? otherwise some useless instructions |
@@ -1920,6 +1943,9 @@ ncls: | |||
1920 | skb = handle_bridge(skb, &pt_prev, &ret, orig_dev); | 1943 | skb = handle_bridge(skb, &pt_prev, &ret, orig_dev); |
1921 | if (!skb) | 1944 | if (!skb) |
1922 | goto out; | 1945 | goto out; |
1946 | skb = handle_macvlan(skb, &pt_prev, &ret, orig_dev); | ||
1947 | if (!skb) | ||
1948 | goto out; | ||
1923 | 1949 | ||
1924 | type = skb->protocol; | 1950 | type = skb->protocol; |
1925 | list_for_each_entry_rcu(ptype, &ptype_base[ntohs(type)&15], list) { | 1951 | list_for_each_entry_rcu(ptype, &ptype_base[ntohs(type)&15], list) { |