[ovs-dev] [threads 01/23] dpif-netdev: Make 'max_mtu' a per-dp feature, for thread safety.
Alex Wang
alexw at nicira.com
Mon Jul 22 15:59:57 UTC 2013
Looks good to me, thanks,
On Thu, Jul 18, 2013 at 4:15 PM, Ben Pfaff <blp at nicira.com> wrote:
> This ensures that an external lock around a dpif_netdev will allow
> thread-safe access to it.
>
> Signed-off-by: Ben Pfaff <blp at nicira.com>
> ---
> lib/dpif-netdev.c | 12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index f7e3b1f..d21eb8d 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -87,6 +87,7 @@ struct dp_netdev {
> char *name;
> int open_cnt;
> bool destroyed;
> + int max_mtu; /* Maximum MTU of any port added so far.
> */
>
> struct dp_netdev_queue queues[N_QUEUES];
> struct hmap flow_table; /* Flow table. */
> @@ -138,9 +139,6 @@ struct dpif_netdev {
> /* All netdev-based datapaths. */
> static struct shash dp_netdevs = SHASH_INITIALIZER(&dp_netdevs);
>
> -/* Maximum port MTU seen so far. */
> -static int max_mtu = ETH_PAYLOAD_MAX;
> -
> static int get_port_by_number(struct dp_netdev *, odp_port_t port_no,
> struct dp_netdev_port **portp);
> static int get_port_by_name(struct dp_netdev *, const char *devname,
> @@ -271,6 +269,7 @@ create_dp_netdev(const char *name, const struct
> dpif_class *class,
> dp->class = class;
> dp->name = xstrdup(name);
> dp->open_cnt = 0;
> + dp->max_mtu = ETH_PAYLOAD_MAX;
> for (i = 0; i < N_QUEUES; i++) {
> dp->queues[i].head = dp->queues[i].tail = 0;
> }
> @@ -426,8 +425,8 @@ do_add_port(struct dp_netdev *dp, const char *devname,
> const char *type,
> port->type = xstrdup(type);
>
> error = netdev_get_mtu(netdev, &mtu);
> - if (!error && mtu > max_mtu) {
> - max_mtu = mtu;
> + if (!error && mtu > dp->max_mtu) {
> + dp->max_mtu = mtu;
> }
>
> list_push_back(&dp->port_list, &port->node);
> @@ -1081,7 +1080,8 @@ dpif_netdev_run(struct dpif *dpif)
> struct dp_netdev_port *port;
> struct ofpbuf packet;
>
> - ofpbuf_init(&packet, DP_NETDEV_HEADROOM + VLAN_ETH_HEADER_LEN +
> max_mtu);
> + ofpbuf_init(&packet,
> + DP_NETDEV_HEADROOM + VLAN_ETH_HEADER_LEN + dp->max_mtu);
>
> LIST_FOR_EACH (port, node, &dp->port_list) {
> int error;
> --
> 1.7.2.5
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20130722/816a5a24/attachment-0003.html>
More information about the dev
mailing list