flow.c \
table.c \
vport.c \
+ vport-generic.c \
vport-gre.c \
vport-internal_dev.c \
vport-netdev.c
odp-compat.h \
table.h \
vport.h \
+ vport-generic.h \
vport-internal_dev.h \
vport-netdev.h
/table.c
/tmp
/veth.c
+/vport-generic.c
/vport-gre.c
/vport-internal_dev.c
/vport-netdev.c
--- /dev/null
+/*
+ * Copyright (c) 2010 Nicira Networks.
+ * Distributed under the terms of the GNU GPL version 2.
+ *
+ * Significant portions of this file may be copied from parts of the Linux
+ * kernel, by Linus Torvalds and others.
+ */
+
+#include <linux/etherdevice.h>
+
+#include "vport-generic.h"
+
+void
+vport_gen_rand_ether_addr(u8 *addr)
+{
+ random_ether_addr(addr);
+
+ /* Set the OUI to the Nicira one. */
+ addr[0] = 0x00;
+ addr[1] = 0x23;
+ addr[2] = 0x20;
+
+ /* Set the top bit to indicate random address. */
+ addr[3] |= 0x80;
+}
+
+unsigned
+vport_gen_get_dev_flags(const struct vport *vport)
+{
+ return IFF_UP | IFF_RUNNING | IFF_LOWER_UP;
+}
+
+int
+vport_gen_is_running(const struct vport *vport)
+{
+ return 1;
+}
+
+unsigned char
+vport_gen_get_operstate(const struct vport *vport)
+{
+ return IF_OPER_UP;
+}
--- /dev/null
+/*
+ * Copyright (c) 2010 Nicira Networks.
+ * Distributed under the terms of the GNU GPL version 2.
+ *
+ * Significant portions of this file may be copied from parts of the Linux
+ * kernel, by Linus Torvalds and others.
+ */
+
+#ifndef VPORT_GENERIC_H
+#define VPORT_GENERIC_H 1
+
+#include "vport.h"
+
+void vport_gen_rand_ether_addr(u8 *addr);
+unsigned vport_gen_get_dev_flags(const struct vport *);
+int vport_gen_is_running(const struct vport *);
+unsigned char vport_gen_get_operstate(const struct vport *);
+
+#endif /* vport-generic.h */
#include "openvswitch/gre.h"
#include "table.h"
#include "vport.h"
+#include "vport-generic.h"
/* The absolute minimum fragment size. Note that there are many other
* definitions of the minimum MTU. */
goto error_free_vport;
}
- vport_gen_ether_addr(gre_vport->mutable->eth_addr);
+ vport_gen_rand_ether_addr(gre_vport->mutable->eth_addr);
gre_vport->mutable->mtu = ETH_DATA_LEN;
err = set_config(NULL, gre_vport->mutable, config);
{
struct gre_vport *gre_vport = gre_vport_priv(vport);
struct mutable_config *mutable;
- struct dp_port *dp_port;
mutable = kmemdup(gre_vport->mutable, sizeof(struct mutable_config), GFP_KERNEL);
if (!mutable)
mutable->mtu = mtu;
assign_config_rcu(vport, mutable);
- dp_port = vport_get_dp_port(vport);
- if (dp_port)
- set_internal_devs_mtu(dp_port->dp);
-
return 0;
}
return rcu_dereference(gre_vport->mutable)->eth_addr;
}
-static unsigned
-gre_get_dev_flags(const struct vport *vport)
-{
- return IFF_UP | IFF_RUNNING | IFF_LOWER_UP;
-}
-
-static int
-gre_is_running(const struct vport *vport)
-{
- return 1;
-}
-
-static unsigned char
-gre_get_operstate(const struct vport *vport)
-{
- return IF_OPER_UP;
-}
-
static int
gre_get_mtu(const struct vport *vport)
{
.set_addr = gre_set_addr,
.get_name = gre_get_name,
.get_addr = gre_get_addr,
- .get_dev_flags = gre_get_dev_flags,
- .is_running = gre_is_running,
- .get_operstate = gre_get_operstate,
+ .get_dev_flags = vport_gen_get_dev_flags,
+ .is_running = vport_gen_is_running,
+ .get_operstate = vport_gen_get_operstate,
.get_mtu = gre_get_mtu,
.send = gre_send,
};
#include "datapath.h"
#include "openvswitch/internal_dev.h"
+#include "vport-generic.h"
#include "vport-internal_dev.h"
#include "vport-netdev.h"
netdev->features = NETIF_F_LLTX | NETIF_F_SG | NETIF_F_HIGHDMA
| NETIF_F_HW_CSUM | NETIF_F_TSO;
- vport_gen_ether_addr(netdev->dev_addr);
+ vport_gen_rand_ether_addr(netdev->dev_addr);
}
static struct vport *
#include <linux/compat.h>
#include "vport.h"
+#include "vport-internal_dev.h"
extern struct vport_ops netdev_vport_ops;
extern struct vport_ops internal_vport_ops;
if (mtu < 68)
return -EINVAL;
- if (vport->ops->set_mtu)
- return vport->ops->set_mtu(vport, mtu);
- else
+ if (vport->ops->set_mtu) {
+ int ret;
+
+ ret = vport->ops->set_mtu(vport, mtu);
+
+ if (!ret && !is_internal_vport(vport)) {
+ struct dp_port *dp_port = vport_get_dp_port(vport);
+
+ if (dp_port)
+ set_internal_devs_mtu(dp_port->dp);
+ }
+
+ return ret;
+ } else
return -EOPNOTSUPP;
}
spin_unlock_bh(&vport->err_stats.lock);
}
}
-
-/**
- * vport_gen_ether_addr - generate an Ethernet address
- *
- * @addr: location to store generated address
- *
- * Generates a random Ethernet address for use when creating a device that
- * has no natural address.
- */
-void
-vport_gen_ether_addr(u8 *addr)
-{
- random_ether_addr(addr);
-
- /* Set the OUI to the Nicira one. */
- addr[0] = 0x00;
- addr[1] = 0x23;
- addr[2] = 0x20;
-
- /* Set the top bit to indicate random address. */
- addr[3] |= 0x80;
-}
void vport_receive(struct vport *, struct sk_buff *);
void vport_record_error(struct vport *, enum vport_err_type err_type);
-void vport_gen_ether_addr(u8 *addr);
#endif /* vport.h */