[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>
This commit is contained in:
committed by
David S. Miller
parent
56addd6eee
commit
b863ceb7dd
@ -98,6 +98,7 @@
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/stat.h>
|
||||
#include <linux/if_bridge.h>
|
||||
#include <linux/if_macvlan.h>
|
||||
#include <net/dst.h>
|
||||
#include <net/pkt_sched.h>
|
||||
#include <net/checksum.h>
|
||||
@ -1813,6 +1814,28 @@ static inline struct sk_buff *handle_bridge(struct sk_buff *skb,
|
||||
#define handle_bridge(skb, pt_prev, ret, orig_dev) (skb)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_MACVLAN) || defined(CONFIG_MACVLAN_MODULE)
|
||||
struct sk_buff *(*macvlan_handle_frame_hook)(struct sk_buff *skb) __read_mostly;
|
||||
EXPORT_SYMBOL_GPL(macvlan_handle_frame_hook);
|
||||
|
||||
static inline struct sk_buff *handle_macvlan(struct sk_buff *skb,
|
||||
struct packet_type **pt_prev,
|
||||
int *ret,
|
||||
struct net_device *orig_dev)
|
||||
{
|
||||
if (skb->dev->macvlan_port == NULL)
|
||||
return skb;
|
||||
|
||||
if (*pt_prev) {
|
||||
*ret = deliver_skb(skb, *pt_prev, orig_dev);
|
||||
*pt_prev = NULL;
|
||||
}
|
||||
return macvlan_handle_frame_hook(skb);
|
||||
}
|
||||
#else
|
||||
#define handle_macvlan(skb, pt_prev, ret, orig_dev) (skb)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_CLS_ACT
|
||||
/* TODO: Maybe we should just force sch_ingress to be compiled in
|
||||
* when CONFIG_NET_CLS_ACT is? otherwise some useless instructions
|
||||
@ -1918,6 +1941,9 @@ ncls:
|
||||
#endif
|
||||
|
||||
skb = handle_bridge(skb, &pt_prev, &ret, orig_dev);
|
||||
if (!skb)
|
||||
goto out;
|
||||
skb = handle_macvlan(skb, &pt_prev, &ret, orig_dev);
|
||||
if (!skb)
|
||||
goto out;
|
||||
|
||||
|
Reference in New Issue
Block a user