5
#include <net/l2/ethernet.h>
7
#include <net/netdevice.h>
8
#include <net/inetdevice.h>
10
#include <net/l0/net_entry.h>
11
#include <net/net_namespace.h>
12
#include <net/netdevice.h>
14
static int veth_xmit(struct net_device *dev,
15
struct sk_buff *skb) {
16
struct net_device_stats *lb_stats;
19
if ((skb == NULL) || (dev == NULL)) {
25
lb_stats = &dev->stats;
27
skb->dev = (struct net_device *) dev->priv;
28
if (netif_rx(skb) == NET_RX_SUCCESS) {
29
lb_stats->rx_packets++;
30
lb_stats->rx_bytes += skb_len;
38
static const struct net_driver veth_ops = {
42
struct net_device *veth_alloc(struct net_device **v1, struct net_device **v2) {
43
struct net_device *veth1, *veth2;
46
veth1 = etherdev_alloc(sizeof(struct net_device *));
50
ret = inetdev_register_dev(veth1);
55
veth2 = etherdev_alloc(sizeof(struct net_device *));
59
ret = inetdev_register_dev(veth2);
64
assign_net_ns(veth1->net_ns, init_net_ns);
65
assign_net_ns(veth2->net_ns, init_net_ns);
66
veth1->priv = (void *)veth2;
67
veth2->priv = (void *)veth1;
68
veth1->drv_ops = &veth_ops;
69
veth2->drv_ops = &veth_ops;
73
return (struct net_device *)1;