mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-01 20:35:06 +00:00
net/ncsi: Don't limit vids based on hot_channel
Currently we drop any new VLAN ids if there are more than the current (or last used) channel can support. Most importantly this is a problem if no channel has been selected yet, resulting in a segfault. Secondly this does not necessarily reflect the capabilities of any other channels. Instead only drop a new VLAN id if we are already tracking the maximum allowed by the NCSI specification. Per-channel limits are already handled by ncsi_add_filter(), but add a message to set_one_vid() to make it obvious that the channel can not support any more VLAN ids. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
bde135a672
commit
6e9c007540
@ -286,6 +286,7 @@ struct ncsi_dev_priv {
|
|||||||
struct work_struct work; /* For channel management */
|
struct work_struct work; /* For channel management */
|
||||||
struct packet_type ptype; /* NCSI packet Rx handler */
|
struct packet_type ptype; /* NCSI packet Rx handler */
|
||||||
struct list_head node; /* Form NCSI device list */
|
struct list_head node; /* Form NCSI device list */
|
||||||
|
#define NCSI_MAX_VLAN_VIDS 15
|
||||||
struct list_head vlan_vids; /* List of active VLAN IDs */
|
struct list_head vlan_vids; /* List of active VLAN IDs */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -732,6 +732,10 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc,
|
|||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
netdev_err(ndp->ndev.dev,
|
netdev_err(ndp->ndev.dev,
|
||||||
"Failed to add new VLAN tag, error %d\n", index);
|
"Failed to add new VLAN tag, error %d\n", index);
|
||||||
|
if (index == -ENOSPC)
|
||||||
|
netdev_err(ndp->ndev.dev,
|
||||||
|
"Channel %u already has all VLAN filters set\n",
|
||||||
|
nc->id);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1403,7 +1407,6 @@ static int ncsi_kick_channels(struct ncsi_dev_priv *ndp)
|
|||||||
|
|
||||||
int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
|
int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
|
||||||
{
|
{
|
||||||
struct ncsi_channel_filter *ncf;
|
|
||||||
struct ncsi_dev_priv *ndp;
|
struct ncsi_dev_priv *ndp;
|
||||||
unsigned int n_vids = 0;
|
unsigned int n_vids = 0;
|
||||||
struct vlan_vid *vlan;
|
struct vlan_vid *vlan;
|
||||||
@ -1420,7 +1423,6 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ndp = TO_NCSI_DEV_PRIV(nd);
|
ndp = TO_NCSI_DEV_PRIV(nd);
|
||||||
ncf = ndp->hot_channel->filters[NCSI_FILTER_VLAN];
|
|
||||||
|
|
||||||
/* Add the VLAN id to our internal list */
|
/* Add the VLAN id to our internal list */
|
||||||
list_for_each_entry_rcu(vlan, &ndp->vlan_vids, list) {
|
list_for_each_entry_rcu(vlan, &ndp->vlan_vids, list) {
|
||||||
@ -1431,12 +1433,11 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (n_vids >= NCSI_MAX_VLAN_VIDS) {
|
||||||
if (n_vids >= ncf->total) {
|
netdev_warn(dev,
|
||||||
netdev_info(dev,
|
"tried to add vlan id %u but NCSI max already registered (%u)\n",
|
||||||
"NCSI Channel supports up to %u VLAN tags but %u are already set\n",
|
vid, NCSI_MAX_VLAN_VIDS);
|
||||||
ncf->total, n_vids);
|
return -ENOSPC;
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);
|
vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);
|
||||||
|
Loading…
Reference in New Issue
Block a user