Commit 42275bd8 authored by Scott Feldman's avatar Scott Feldman Committed by David S. Miller

switchdev: don't use anonymous union on switchdev attr/obj structs

Older gcc versions (e.g.  gcc version 4.4.6) don't like anonymous unions
which was causing build issues on the newly added switchdev attr/obj
structs.  Fix this by using named union on structs.
Signed-off-by: default avatarScott Feldman <sfeldma@gmail.com>
Reported-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1f7bd29b
...@@ -4339,11 +4339,11 @@ static int rocker_port_attr_get(struct net_device *dev, ...@@ -4339,11 +4339,11 @@ static int rocker_port_attr_get(struct net_device *dev,
switch (attr->id) { switch (attr->id) {
case SWITCHDEV_ATTR_PORT_PARENT_ID: case SWITCHDEV_ATTR_PORT_PARENT_ID:
attr->ppid.id_len = sizeof(rocker->hw.id); attr->u.ppid.id_len = sizeof(rocker->hw.id);
memcpy(&attr->ppid.id, &rocker->hw.id, attr->ppid.id_len); memcpy(&attr->u.ppid.id, &rocker->hw.id, attr->u.ppid.id_len);
break; break;
case SWITCHDEV_ATTR_PORT_BRIDGE_FLAGS: case SWITCHDEV_ATTR_PORT_BRIDGE_FLAGS:
attr->brport_flags = rocker_port->brport_flags; attr->u.brport_flags = rocker_port->brport_flags;
break; break;
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -4400,11 +4400,11 @@ static int rocker_port_attr_set(struct net_device *dev, ...@@ -4400,11 +4400,11 @@ static int rocker_port_attr_set(struct net_device *dev,
switch (attr->id) { switch (attr->id) {
case SWITCHDEV_ATTR_PORT_STP_STATE: case SWITCHDEV_ATTR_PORT_STP_STATE:
err = rocker_port_stp_update(rocker_port, attr->trans, err = rocker_port_stp_update(rocker_port, attr->trans,
attr->stp_state); attr->u.stp_state);
break; break;
case SWITCHDEV_ATTR_PORT_BRIDGE_FLAGS: case SWITCHDEV_ATTR_PORT_BRIDGE_FLAGS:
err = rocker_port_brport_flags_set(rocker_port, attr->trans, err = rocker_port_brport_flags_set(rocker_port, attr->trans,
attr->brport_flags); attr->u.brport_flags);
break; break;
default: default:
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
...@@ -4466,10 +4466,10 @@ static int rocker_port_obj_add(struct net_device *dev, ...@@ -4466,10 +4466,10 @@ static int rocker_port_obj_add(struct net_device *dev,
switch (obj->id) { switch (obj->id) {
case SWITCHDEV_OBJ_PORT_VLAN: case SWITCHDEV_OBJ_PORT_VLAN:
err = rocker_port_vlans_add(rocker_port, obj->trans, err = rocker_port_vlans_add(rocker_port, obj->trans,
&obj->vlan); &obj->u.vlan);
break; break;
case SWITCHDEV_OBJ_IPV4_FIB: case SWITCHDEV_OBJ_IPV4_FIB:
fib4 = &obj->ipv4_fib; fib4 = &obj->u.ipv4_fib;
err = rocker_port_fib_ipv4(rocker_port, obj->trans, err = rocker_port_fib_ipv4(rocker_port, obj->trans,
htonl(fib4->dst), fib4->dst_len, htonl(fib4->dst), fib4->dst_len,
fib4->fi, fib4->tb_id, 0); fib4->fi, fib4->tb_id, 0);
...@@ -4520,10 +4520,10 @@ static int rocker_port_obj_del(struct net_device *dev, ...@@ -4520,10 +4520,10 @@ static int rocker_port_obj_del(struct net_device *dev,
switch (obj->id) { switch (obj->id) {
case SWITCHDEV_OBJ_PORT_VLAN: case SWITCHDEV_OBJ_PORT_VLAN:
err = rocker_port_vlans_del(rocker_port, &obj->vlan); err = rocker_port_vlans_del(rocker_port, &obj->u.vlan);
break; break;
case SWITCHDEV_OBJ_IPV4_FIB: case SWITCHDEV_OBJ_IPV4_FIB:
fib4 = &obj->ipv4_fib; fib4 = &obj->u.ipv4_fib;
err = rocker_port_fib_ipv4(rocker_port, SWITCHDEV_TRANS_NONE, err = rocker_port_fib_ipv4(rocker_port, SWITCHDEV_TRANS_NONE,
htonl(fib4->dst), fib4->dst_len, htonl(fib4->dst), fib4->dst_len,
fib4->fi, fib4->tb_id, fib4->fi, fib4->tb_id,
......
...@@ -38,7 +38,7 @@ struct switchdev_attr { ...@@ -38,7 +38,7 @@ struct switchdev_attr {
struct netdev_phys_item_id ppid; /* PORT_PARENT_ID */ struct netdev_phys_item_id ppid; /* PORT_PARENT_ID */
u8 stp_state; /* PORT_STP_STATE */ u8 stp_state; /* PORT_STP_STATE */
unsigned long brport_flags; /* PORT_BRIDGE_FLAGS */ unsigned long brport_flags; /* PORT_BRIDGE_FLAGS */
}; } u;
}; };
struct fib_info; struct fib_info;
...@@ -67,7 +67,7 @@ struct switchdev_obj { ...@@ -67,7 +67,7 @@ struct switchdev_obj {
u32 nlflags; u32 nlflags;
u32 tb_id; u32 tb_id;
} ipv4_fib; } ipv4_fib;
}; } u;
}; };
/** /**
......
...@@ -41,7 +41,7 @@ void br_set_state(struct net_bridge_port *p, unsigned int state) ...@@ -41,7 +41,7 @@ void br_set_state(struct net_bridge_port *p, unsigned int state)
{ {
struct switchdev_attr attr = { struct switchdev_attr attr = {
.id = SWITCHDEV_ATTR_PORT_STP_STATE, .id = SWITCHDEV_ATTR_PORT_STP_STATE,
.stp_state = state, .u.stp_state = state,
}; };
int err; int err;
......
...@@ -465,8 +465,8 @@ static ssize_t phys_switch_id_show(struct device *dev, ...@@ -465,8 +465,8 @@ static ssize_t phys_switch_id_show(struct device *dev,
ret = switchdev_port_attr_get(netdev, &attr); ret = switchdev_port_attr_get(netdev, &attr);
if (!ret) if (!ret)
ret = sprintf(buf, "%*phN\n", attr.ppid.id_len, ret = sprintf(buf, "%*phN\n", attr.u.ppid.id_len,
attr.ppid.id); attr.u.ppid.id);
} }
rtnl_unlock(); rtnl_unlock();
......
...@@ -1016,7 +1016,8 @@ static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device *dev) ...@@ -1016,7 +1016,8 @@ static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device *dev)
return err; return err;
} }
if (nla_put(skb, IFLA_PHYS_SWITCH_ID, attr.ppid.id_len, attr.ppid.id)) if (nla_put(skb, IFLA_PHYS_SWITCH_ID, attr.u.ppid.id_len,
attr.u.ppid.id))
return -EMSGSIZE; return -EMSGSIZE;
return 0; return 0;
......
...@@ -353,7 +353,7 @@ static int dsa_slave_port_attr_set(struct net_device *dev, ...@@ -353,7 +353,7 @@ static int dsa_slave_port_attr_set(struct net_device *dev,
switch (attr->id) { switch (attr->id) {
case SWITCHDEV_ATTR_PORT_STP_STATE: case SWITCHDEV_ATTR_PORT_STP_STATE:
if (attr->trans == SWITCHDEV_TRANS_COMMIT) if (attr->trans == SWITCHDEV_TRANS_COMMIT)
ret = dsa_slave_stp_update(dev, attr->stp_state); ret = dsa_slave_stp_update(dev, attr->u.stp_state);
break; break;
default: default:
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
...@@ -408,8 +408,8 @@ static int dsa_slave_port_attr_get(struct net_device *dev, ...@@ -408,8 +408,8 @@ static int dsa_slave_port_attr_get(struct net_device *dev,
switch (attr->id) { switch (attr->id) {
case SWITCHDEV_ATTR_PORT_PARENT_ID: case SWITCHDEV_ATTR_PORT_PARENT_ID:
attr->ppid.id_len = sizeof(ds->index); attr->u.ppid.id_len = sizeof(ds->index);
memcpy(&attr->ppid.id, &ds->index, attr->ppid.id_len); memcpy(&attr->u.ppid.id, &ds->index, attr->u.ppid.id_len);
break; break;
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
...@@ -383,7 +383,7 @@ int switchdev_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, ...@@ -383,7 +383,7 @@ int switchdev_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
return err; return err;
return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode, return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode,
attr.brport_flags, mask, nlflags); attr.u.brport_flags, mask, nlflags);
} }
EXPORT_SYMBOL_GPL(switchdev_port_bridge_getlink); EXPORT_SYMBOL_GPL(switchdev_port_bridge_getlink);
...@@ -402,9 +402,9 @@ static int switchdev_port_br_setflag(struct net_device *dev, ...@@ -402,9 +402,9 @@ static int switchdev_port_br_setflag(struct net_device *dev,
return err; return err;
if (flag) if (flag)
attr.brport_flags |= brport_flag; attr.u.brport_flags |= brport_flag;
else else
attr.brport_flags &= ~brport_flag; attr.u.brport_flags &= ~brport_flag;
return switchdev_port_attr_set(dev, &attr); return switchdev_port_attr_set(dev, &attr);
} }
...@@ -466,6 +466,7 @@ static int switchdev_port_br_afspec(struct net_device *dev, ...@@ -466,6 +466,7 @@ static int switchdev_port_br_afspec(struct net_device *dev,
struct switchdev_obj obj = { struct switchdev_obj obj = {
.id = SWITCHDEV_OBJ_PORT_VLAN, .id = SWITCHDEV_OBJ_PORT_VLAN,
}; };
struct switchdev_obj_vlan *vlan = &obj.u.vlan;
int rem; int rem;
int err; int err;
...@@ -475,30 +476,30 @@ static int switchdev_port_br_afspec(struct net_device *dev, ...@@ -475,30 +476,30 @@ static int switchdev_port_br_afspec(struct net_device *dev,
if (nla_len(attr) != sizeof(struct bridge_vlan_info)) if (nla_len(attr) != sizeof(struct bridge_vlan_info))
return -EINVAL; return -EINVAL;
vinfo = nla_data(attr); vinfo = nla_data(attr);
obj.vlan.flags = vinfo->flags; vlan->flags = vinfo->flags;
if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) { if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) {
if (obj.vlan.vid_start) if (vlan->vid_start)
return -EINVAL; return -EINVAL;
obj.vlan.vid_start = vinfo->vid; vlan->vid_start = vinfo->vid;
} else if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_END) { } else if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_END) {
if (!obj.vlan.vid_start) if (!vlan->vid_start)
return -EINVAL; return -EINVAL;
obj.vlan.vid_end = vinfo->vid; vlan->vid_end = vinfo->vid;
if (obj.vlan.vid_end <= obj.vlan.vid_start) if (vlan->vid_end <= vlan->vid_start)
return -EINVAL; return -EINVAL;
err = f(dev, &obj); err = f(dev, &obj);
if (err) if (err)
return err; return err;
memset(&obj.vlan, 0, sizeof(obj.vlan)); memset(vlan, 0, sizeof(*vlan));
} else { } else {
if (obj.vlan.vid_start) if (vlan->vid_start)
return -EINVAL; return -EINVAL;
obj.vlan.vid_start = vinfo->vid; vlan->vid_start = vinfo->vid;
obj.vlan.vid_end = vinfo->vid; vlan->vid_end = vinfo->vid;
err = f(dev, &obj); err = f(dev, &obj);
if (err) if (err)
return err; return err;
memset(&obj.vlan, 0, sizeof(obj.vlan)); memset(vlan, 0, sizeof(*vlan));
} }
} }
...@@ -613,10 +614,10 @@ static struct net_device *switchdev_get_dev_by_nhs(struct fib_info *fi) ...@@ -613,10 +614,10 @@ static struct net_device *switchdev_get_dev_by_nhs(struct fib_info *fi)
return NULL; return NULL;
if (nhsel > 0) { if (nhsel > 0) {
if (prev_attr.ppid.id_len != attr.ppid.id_len) if (prev_attr.u.ppid.id_len != attr.u.ppid.id_len)
return NULL; return NULL;
if (memcmp(prev_attr.ppid.id, attr.ppid.id, if (memcmp(prev_attr.u.ppid.id, attr.u.ppid.id,
attr.ppid.id_len)) attr.u.ppid.id_len))
return NULL; return NULL;
} }
...@@ -644,7 +645,7 @@ int switchdev_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi, ...@@ -644,7 +645,7 @@ int switchdev_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
{ {
struct switchdev_obj fib_obj = { struct switchdev_obj fib_obj = {
.id = SWITCHDEV_OBJ_IPV4_FIB, .id = SWITCHDEV_OBJ_IPV4_FIB,
.ipv4_fib = { .u.ipv4_fib = {
.dst = dst, .dst = dst,
.dst_len = dst_len, .dst_len = dst_len,
.fi = fi, .fi = fi,
...@@ -698,7 +699,7 @@ int switchdev_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi, ...@@ -698,7 +699,7 @@ int switchdev_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
{ {
struct switchdev_obj fib_obj = { struct switchdev_obj fib_obj = {
.id = SWITCHDEV_OBJ_IPV4_FIB, .id = SWITCHDEV_OBJ_IPV4_FIB,
.ipv4_fib = { .u.ipv4_fib = {
.dst = dst, .dst = dst,
.dst_len = dst_len, .dst_len = dst_len,
.fi = fi, .fi = fi,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment