From: sfel...@gmail.com
Date: Thu, 11 Jun 2015 12:15:22 -0700

> +static int __vlan_vid_add(struct net_device *dev, struct net_bridge *br,
> +                       u16 vid, u16 flags)
> +{
> +     const struct net_device_ops *ops = dev->netdev_ops;
> +     struct switchdev_obj vlan_obj = {
> +             .id = SWITCHDEV_OBJ_PORT_VLAN,
> +             .u.vlan = {
> +                     .flags = flags,
> +                     .vid_start = vid,
> +                     .vid_end = vid,
> +             },
> +     };
> +     int err;
> +
> +     /* If driver uses VLAN ndo ops, use 8021q to install vid
> +      * on device, otherwise try switchdev ops to install vid.
> +      */
> +
> +     if (ops->ndo_vlan_rx_add_vid) {
> +             err = vlan_vid_add(dev, br->vlan_proto, vid);
> +     } else {
> +             err = switchdev_port_obj_add(dev, &vlan_obj);
> +             if (err == -EOPNOTSUPP)
> +                     err = 0;
> +     }

I know this looks like nit-picking, but would you please instantiate
the on-stack vlan_obj in the deepest basic block it is used inside
of?  Which here is the else branch.

> +static void __vlan_vid_del(struct net_device *dev, struct net_bridge *br,
> +                        u16 vid)
> +{
> +     const struct net_device_ops *ops = dev->netdev_ops;
> +     struct switchdev_obj vlan_obj = {
> +             .id = SWITCHDEV_OBJ_PORT_VLAN,
> +             .u.vlan = {
> +                     .vid_start = vid,
> +                     .vid_end = vid,
> +             },
> +     };
> +
> +     /* If driver uses VLAN ndo ops, use 8021q to delete vid
> +      * on device, otherwise try switchdev ops to delete vid.
> +      */
> +
> +     if (ops->ndo_vlan_rx_kill_vid)
> +             vlan_vid_del(dev, br->vlan_proto, vid);
> +     else
> +             switchdev_port_obj_del(dev, &vlan_obj);

Likewise.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to