Commit d1b19dff authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: net/core/dev.c cleanups

Pure style cleanup patch before surgery :)
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 137742cf
...@@ -191,7 +191,6 @@ static struct list_head ptype_all __read_mostly; /* Taps */ ...@@ -191,7 +191,6 @@ static struct list_head ptype_all __read_mostly; /* Taps */
* semaphore held. * semaphore held.
*/ */
DEFINE_RWLOCK(dev_base_lock); DEFINE_RWLOCK(dev_base_lock);
EXPORT_SYMBOL(dev_base_lock); EXPORT_SYMBOL(dev_base_lock);
#define NETDEV_HASHBITS 8 #define NETDEV_HASHBITS 8
...@@ -248,6 +247,7 @@ static RAW_NOTIFIER_HEAD(netdev_chain); ...@@ -248,6 +247,7 @@ static RAW_NOTIFIER_HEAD(netdev_chain);
*/ */
DEFINE_PER_CPU(struct softnet_data, softnet_data); DEFINE_PER_CPU(struct softnet_data, softnet_data);
EXPORT_PER_CPU_SYMBOL(softnet_data);
#ifdef CONFIG_LOCKDEP #ifdef CONFIG_LOCKDEP
/* /*
...@@ -381,6 +381,7 @@ void dev_add_pack(struct packet_type *pt) ...@@ -381,6 +381,7 @@ void dev_add_pack(struct packet_type *pt)
} }
spin_unlock_bh(&ptype_lock); spin_unlock_bh(&ptype_lock);
} }
EXPORT_SYMBOL(dev_add_pack);
/** /**
* __dev_remove_pack - remove packet handler * __dev_remove_pack - remove packet handler
...@@ -418,6 +419,8 @@ void __dev_remove_pack(struct packet_type *pt) ...@@ -418,6 +419,8 @@ void __dev_remove_pack(struct packet_type *pt)
out: out:
spin_unlock_bh(&ptype_lock); spin_unlock_bh(&ptype_lock);
} }
EXPORT_SYMBOL(__dev_remove_pack);
/** /**
* dev_remove_pack - remove packet handler * dev_remove_pack - remove packet handler
* @pt: packet type declaration * @pt: packet type declaration
...@@ -436,6 +439,7 @@ void dev_remove_pack(struct packet_type *pt) ...@@ -436,6 +439,7 @@ void dev_remove_pack(struct packet_type *pt)
synchronize_net(); synchronize_net();
} }
EXPORT_SYMBOL(dev_remove_pack);
/****************************************************************************** /******************************************************************************
...@@ -499,6 +503,7 @@ int netdev_boot_setup_check(struct net_device *dev) ...@@ -499,6 +503,7 @@ int netdev_boot_setup_check(struct net_device *dev)
} }
return 0; return 0;
} }
EXPORT_SYMBOL(netdev_boot_setup_check);
/** /**
...@@ -591,6 +596,7 @@ struct net_device *__dev_get_by_name(struct net *net, const char *name) ...@@ -591,6 +596,7 @@ struct net_device *__dev_get_by_name(struct net *net, const char *name)
} }
return NULL; return NULL;
} }
EXPORT_SYMBOL(__dev_get_by_name);
/** /**
* dev_get_by_name - find a device by its name * dev_get_by_name - find a device by its name
...@@ -615,6 +621,7 @@ struct net_device *dev_get_by_name(struct net *net, const char *name) ...@@ -615,6 +621,7 @@ struct net_device *dev_get_by_name(struct net *net, const char *name)
read_unlock(&dev_base_lock); read_unlock(&dev_base_lock);
return dev; return dev;
} }
EXPORT_SYMBOL(dev_get_by_name);
/** /**
* __dev_get_by_index - find a device by its ifindex * __dev_get_by_index - find a device by its ifindex
...@@ -640,6 +647,7 @@ struct net_device *__dev_get_by_index(struct net *net, int ifindex) ...@@ -640,6 +647,7 @@ struct net_device *__dev_get_by_index(struct net *net, int ifindex)
} }
return NULL; return NULL;
} }
EXPORT_SYMBOL(__dev_get_by_index);
/** /**
...@@ -664,6 +672,7 @@ struct net_device *dev_get_by_index(struct net *net, int ifindex) ...@@ -664,6 +672,7 @@ struct net_device *dev_get_by_index(struct net *net, int ifindex)
read_unlock(&dev_base_lock); read_unlock(&dev_base_lock);
return dev; return dev;
} }
EXPORT_SYMBOL(dev_get_by_index);
/** /**
* dev_getbyhwaddr - find a device by its hardware address * dev_getbyhwaddr - find a device by its hardware address
...@@ -693,7 +702,6 @@ struct net_device *dev_getbyhwaddr(struct net *net, unsigned short type, char *h ...@@ -693,7 +702,6 @@ struct net_device *dev_getbyhwaddr(struct net *net, unsigned short type, char *h
return NULL; return NULL;
} }
EXPORT_SYMBOL(dev_getbyhwaddr); EXPORT_SYMBOL(dev_getbyhwaddr);
struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type) struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type)
...@@ -707,7 +715,6 @@ struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type) ...@@ -707,7 +715,6 @@ struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type)
return NULL; return NULL;
} }
EXPORT_SYMBOL(__dev_getfirstbyhwtype); EXPORT_SYMBOL(__dev_getfirstbyhwtype);
struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type) struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type)
...@@ -721,7 +728,6 @@ struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type) ...@@ -721,7 +728,6 @@ struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type)
rtnl_unlock(); rtnl_unlock();
return dev; return dev;
} }
EXPORT_SYMBOL(dev_getfirstbyhwtype); EXPORT_SYMBOL(dev_getfirstbyhwtype);
/** /**
...@@ -736,7 +742,8 @@ EXPORT_SYMBOL(dev_getfirstbyhwtype); ...@@ -736,7 +742,8 @@ EXPORT_SYMBOL(dev_getfirstbyhwtype);
* dev_put to indicate they have finished with it. * dev_put to indicate they have finished with it.
*/ */
struct net_device * dev_get_by_flags(struct net *net, unsigned short if_flags, unsigned short mask) struct net_device *dev_get_by_flags(struct net *net, unsigned short if_flags,
unsigned short mask)
{ {
struct net_device *dev, *ret; struct net_device *dev, *ret;
...@@ -752,6 +759,7 @@ struct net_device * dev_get_by_flags(struct net *net, unsigned short if_flags, u ...@@ -752,6 +759,7 @@ struct net_device * dev_get_by_flags(struct net *net, unsigned short if_flags, u
read_unlock(&dev_base_lock); read_unlock(&dev_base_lock);
return ret; return ret;
} }
EXPORT_SYMBOL(dev_get_by_flags);
/** /**
* dev_valid_name - check if name is okay for network device * dev_valid_name - check if name is okay for network device
...@@ -777,6 +785,7 @@ int dev_valid_name(const char *name) ...@@ -777,6 +785,7 @@ int dev_valid_name(const char *name)
} }
return 1; return 1;
} }
EXPORT_SYMBOL(dev_valid_name);
/** /**
* __dev_alloc_name - allocate a name for a device * __dev_alloc_name - allocate a name for a device
...@@ -870,6 +879,7 @@ int dev_alloc_name(struct net_device *dev, const char *name) ...@@ -870,6 +879,7 @@ int dev_alloc_name(struct net_device *dev, const char *name)
strlcpy(dev->name, buf, IFNAMSIZ); strlcpy(dev->name, buf, IFNAMSIZ);
return ret; return ret;
} }
EXPORT_SYMBOL(dev_alloc_name);
/** /**
...@@ -906,8 +916,7 @@ int dev_change_name(struct net_device *dev, const char *newname) ...@@ -906,8 +916,7 @@ int dev_change_name(struct net_device *dev, const char *newname)
err = dev_alloc_name(dev, newname); err = dev_alloc_name(dev, newname);
if (err < 0) if (err < 0)
return err; return err;
} } else if (__dev_get_by_name(net, newname))
else if (__dev_get_by_name(net, newname))
return -EEXIST; return -EEXIST;
else else
strlcpy(dev->name, newname, IFNAMSIZ); strlcpy(dev->name, newname, IFNAMSIZ);
...@@ -970,7 +979,7 @@ int dev_set_alias(struct net_device *dev, const char *alias, size_t len) ...@@ -970,7 +979,7 @@ int dev_set_alias(struct net_device *dev, const char *alias, size_t len)
return 0; return 0;
} }
dev->ifalias = krealloc(dev->ifalias, len+1, GFP_KERNEL); dev->ifalias = krealloc(dev->ifalias, len + 1, GFP_KERNEL);
if (!dev->ifalias) if (!dev->ifalias)
return -ENOMEM; return -ENOMEM;
...@@ -1006,6 +1015,7 @@ void netdev_state_change(struct net_device *dev) ...@@ -1006,6 +1015,7 @@ void netdev_state_change(struct net_device *dev)
rtmsg_ifinfo(RTM_NEWLINK, dev, 0); rtmsg_ifinfo(RTM_NEWLINK, dev, 0);
} }
} }
EXPORT_SYMBOL(netdev_state_change);
void netdev_bonding_change(struct net_device *dev) void netdev_bonding_change(struct net_device *dev)
{ {
...@@ -1034,6 +1044,7 @@ void dev_load(struct net *net, const char *name) ...@@ -1034,6 +1044,7 @@ void dev_load(struct net *net, const char *name)
if (!dev && capable(CAP_SYS_MODULE)) if (!dev && capable(CAP_SYS_MODULE))
request_module("%s", name); request_module("%s", name);
} }
EXPORT_SYMBOL(dev_load);
/** /**
* dev_open - prepare an interface for use. * dev_open - prepare an interface for use.
...@@ -1118,6 +1129,7 @@ int dev_open(struct net_device *dev) ...@@ -1118,6 +1129,7 @@ int dev_open(struct net_device *dev)
return ret; return ret;
} }
EXPORT_SYMBOL(dev_open);
/** /**
* dev_close - shutdown an interface. * dev_close - shutdown an interface.
...@@ -1184,6 +1196,7 @@ int dev_close(struct net_device *dev) ...@@ -1184,6 +1196,7 @@ int dev_close(struct net_device *dev)
return 0; return 0;
} }
EXPORT_SYMBOL(dev_close);
/** /**
...@@ -1279,6 +1292,7 @@ int register_netdevice_notifier(struct notifier_block *nb) ...@@ -1279,6 +1292,7 @@ int register_netdevice_notifier(struct notifier_block *nb)
raw_notifier_chain_unregister(&netdev_chain, nb); raw_notifier_chain_unregister(&netdev_chain, nb);
goto unlock; goto unlock;
} }
EXPORT_SYMBOL(register_netdevice_notifier);
/** /**
* unregister_netdevice_notifier - unregister a network notifier block * unregister_netdevice_notifier - unregister a network notifier block
...@@ -1299,6 +1313,7 @@ int unregister_netdevice_notifier(struct notifier_block *nb) ...@@ -1299,6 +1313,7 @@ int unregister_netdevice_notifier(struct notifier_block *nb)
rtnl_unlock(); rtnl_unlock();
return err; return err;
} }
EXPORT_SYMBOL(unregister_netdevice_notifier);
/** /**
* call_netdevice_notifiers - call all network notifier blocks * call_netdevice_notifiers - call all network notifier blocks
...@@ -1321,11 +1336,13 @@ void net_enable_timestamp(void) ...@@ -1321,11 +1336,13 @@ void net_enable_timestamp(void)
{ {
atomic_inc(&netstamp_needed); atomic_inc(&netstamp_needed);
} }
EXPORT_SYMBOL(net_enable_timestamp);
void net_disable_timestamp(void) void net_disable_timestamp(void)
{ {
atomic_dec(&netstamp_needed); atomic_dec(&netstamp_needed);
} }
EXPORT_SYMBOL(net_disable_timestamp);
static inline void net_timestamp(struct sk_buff *skb) static inline void net_timestamp(struct sk_buff *skb)
{ {
...@@ -1359,7 +1376,7 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) ...@@ -1359,7 +1376,7 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
if ((ptype->dev == dev || !ptype->dev) && if ((ptype->dev == dev || !ptype->dev) &&
(ptype->af_packet_priv == NULL || (ptype->af_packet_priv == NULL ||
(struct sock *)ptype->af_packet_priv != skb->sk)) { (struct sock *)ptype->af_packet_priv != skb->sk)) {
struct sk_buff *skb2= skb_clone(skb, GFP_ATOMIC); struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
if (!skb2) if (!skb2)
break; break;
...@@ -1527,6 +1544,7 @@ int skb_checksum_help(struct sk_buff *skb) ...@@ -1527,6 +1544,7 @@ int skb_checksum_help(struct sk_buff *skb)
out: out:
return ret; return ret;
} }
EXPORT_SYMBOL(skb_checksum_help);
/** /**
* skb_gso_segment - Perform segmentation on skb. * skb_gso_segment - Perform segmentation on skb.
...@@ -1589,7 +1607,6 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features) ...@@ -1589,7 +1607,6 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features)
return segs; return segs;
} }
EXPORT_SYMBOL(skb_gso_segment); EXPORT_SYMBOL(skb_gso_segment);
/* Take action when hardware reception checksum errors are detected. */ /* Take action when hardware reception checksum errors are detected. */
...@@ -1755,7 +1772,7 @@ u16 skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb) ...@@ -1755,7 +1772,7 @@ u16 skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb)
if (skb_rx_queue_recorded(skb)) { if (skb_rx_queue_recorded(skb)) {
hash = skb_get_rx_queue(skb); hash = skb_get_rx_queue(skb);
while (unlikely (hash >= dev->real_num_tx_queues)) while (unlikely(hash >= dev->real_num_tx_queues))
hash -= dev->real_num_tx_queues; hash -= dev->real_num_tx_queues;
return hash; return hash;
} }
...@@ -1890,7 +1907,7 @@ int dev_queue_xmit(struct sk_buff *skb) ...@@ -1890,7 +1907,7 @@ int dev_queue_xmit(struct sk_buff *skb)
q = rcu_dereference(txq->qdisc); q = rcu_dereference(txq->qdisc);
#ifdef CONFIG_NET_CLS_ACT #ifdef CONFIG_NET_CLS_ACT
skb->tc_verd = SET_TC_AT(skb->tc_verd,AT_EGRESS); skb->tc_verd = SET_TC_AT(skb->tc_verd, AT_EGRESS);
#endif #endif
if (q->enqueue) { if (q->enqueue) {
rc = __dev_xmit_skb(skb, q, dev, txq); rc = __dev_xmit_skb(skb, q, dev, txq);
...@@ -1946,6 +1963,7 @@ int dev_queue_xmit(struct sk_buff *skb) ...@@ -1946,6 +1963,7 @@ int dev_queue_xmit(struct sk_buff *skb)
rcu_read_unlock_bh(); rcu_read_unlock_bh();
return rc; return rc;
} }
EXPORT_SYMBOL(dev_queue_xmit);
/*======================================================================= /*=======================================================================
...@@ -2012,6 +2030,7 @@ int netif_rx(struct sk_buff *skb) ...@@ -2012,6 +2030,7 @@ int netif_rx(struct sk_buff *skb)
kfree_skb(skb); kfree_skb(skb);
return NET_RX_DROP; return NET_RX_DROP;
} }
EXPORT_SYMBOL(netif_rx);
int netif_rx_ni(struct sk_buff *skb) int netif_rx_ni(struct sk_buff *skb)
{ {
...@@ -2025,7 +2044,6 @@ int netif_rx_ni(struct sk_buff *skb) ...@@ -2025,7 +2044,6 @@ int netif_rx_ni(struct sk_buff *skb)
return err; return err;
} }
EXPORT_SYMBOL(netif_rx_ni); EXPORT_SYMBOL(netif_rx_ni);
static void net_tx_action(struct softirq_action *h) static void net_tx_action(struct softirq_action *h)
...@@ -2358,6 +2376,7 @@ int netif_receive_skb(struct sk_buff *skb) ...@@ -2358,6 +2376,7 @@ int netif_receive_skb(struct sk_buff *skb)
rcu_read_unlock(); rcu_read_unlock();
return ret; return ret;
} }
EXPORT_SYMBOL(netif_receive_skb);
/* Network device is going away, flush any packets still pending */ /* Network device is going away, flush any packets still pending */
static void flush_backlog(void *arg) static void flush_backlog(void *arg)
...@@ -2874,7 +2893,7 @@ static void net_rx_action(struct softirq_action *h) ...@@ -2874,7 +2893,7 @@ static void net_rx_action(struct softirq_action *h)
goto out; goto out;
} }
static gifconf_func_t * gifconf_list [NPROTO]; static gifconf_func_t *gifconf_list[NPROTO];
/** /**
* register_gifconf - register a SIOCGIF handler * register_gifconf - register a SIOCGIF handler
...@@ -2885,13 +2904,14 @@ static gifconf_func_t * gifconf_list [NPROTO]; ...@@ -2885,13 +2904,14 @@ static gifconf_func_t * gifconf_list [NPROTO];
* that is passed must not be freed or reused until it has been replaced * that is passed must not be freed or reused until it has been replaced
* by another handler. * by another handler.
*/ */
int register_gifconf(unsigned int family, gifconf_func_t * gifconf) int register_gifconf(unsigned int family, gifconf_func_t *gifconf)
{ {
if (family >= NPROTO) if (family >= NPROTO)
return -EINVAL; return -EINVAL;
gifconf_list[family] = gifconf; gifconf_list[family] = gifconf;
return 0; return 0;
} }
EXPORT_SYMBOL(register_gifconf);
/* /*
...@@ -3102,7 +3122,7 @@ static int softnet_seq_show(struct seq_file *seq, void *v) ...@@ -3102,7 +3122,7 @@ static int softnet_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, "%08x %08x %08x %08x %08x %08x %08x %08x %08x\n", seq_printf(seq, "%08x %08x %08x %08x %08x %08x %08x %08x %08x\n",
s->total, s->dropped, s->time_squeeze, 0, s->total, s->dropped, s->time_squeeze, 0,
0, 0, 0, 0, /* was fastroute */ 0, 0, 0, 0, /* was fastroute */
s->cpu_collision ); s->cpu_collision);
return 0; return 0;
} }
...@@ -3338,6 +3358,7 @@ int netdev_set_master(struct net_device *slave, struct net_device *master) ...@@ -3338,6 +3358,7 @@ int netdev_set_master(struct net_device *slave, struct net_device *master)
rtmsg_ifinfo(RTM_NEWLINK, slave, IFF_SLAVE); rtmsg_ifinfo(RTM_NEWLINK, slave, IFF_SLAVE);
return 0; return 0;
} }
EXPORT_SYMBOL(netdev_set_master);
static void dev_change_rx_flags(struct net_device *dev, int flags) static void dev_change_rx_flags(struct net_device *dev, int flags)
{ {
...@@ -3416,6 +3437,7 @@ int dev_set_promiscuity(struct net_device *dev, int inc) ...@@ -3416,6 +3437,7 @@ int dev_set_promiscuity(struct net_device *dev, int inc)
dev_set_rx_mode(dev); dev_set_rx_mode(dev);
return err; return err;
} }
EXPORT_SYMBOL(dev_set_promiscuity);
/** /**
* dev_set_allmulti - update allmulti count on a device * dev_set_allmulti - update allmulti count on a device
...@@ -3459,6 +3481,7 @@ int dev_set_allmulti(struct net_device *dev, int inc) ...@@ -3459,6 +3481,7 @@ int dev_set_allmulti(struct net_device *dev, int inc)
} }
return 0; return 0;
} }
EXPORT_SYMBOL(dev_set_allmulti);
/* /*
* Upload unicast and multicast address lists to device and * Upload unicast and multicast address lists to device and
...@@ -4088,6 +4111,7 @@ unsigned dev_get_flags(const struct net_device *dev) ...@@ -4088,6 +4111,7 @@ unsigned dev_get_flags(const struct net_device *dev)
return flags; return flags;
} }
EXPORT_SYMBOL(dev_get_flags);
/** /**
* dev_change_flags - change device settings * dev_change_flags - change device settings
...@@ -4138,12 +4162,13 @@ int dev_change_flags(struct net_device *dev, unsigned flags) ...@@ -4138,12 +4162,13 @@ int dev_change_flags(struct net_device *dev, unsigned flags)
} }
if (dev->flags & IFF_UP && if (dev->flags & IFF_UP &&
((old_flags ^ dev->flags) &~ (IFF_UP | IFF_PROMISC | IFF_ALLMULTI | ((old_flags ^ dev->flags) & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI |
IFF_VOLATILE))) IFF_VOLATILE)))
call_netdevice_notifiers(NETDEV_CHANGE, dev); call_netdevice_notifiers(NETDEV_CHANGE, dev);
if ((flags ^ dev->gflags) & IFF_PROMISC) { if ((flags ^ dev->gflags) & IFF_PROMISC) {
int inc = (flags & IFF_PROMISC) ? +1 : -1; int inc = (flags & IFF_PROMISC) ? 1 : -1;
dev->gflags ^= IFF_PROMISC; dev->gflags ^= IFF_PROMISC;
dev_set_promiscuity(dev, inc); dev_set_promiscuity(dev, inc);
} }
...@@ -4153,7 +4178,8 @@ int dev_change_flags(struct net_device *dev, unsigned flags) ...@@ -4153,7 +4178,8 @@ int dev_change_flags(struct net_device *dev, unsigned flags)
IFF_ALLMULTI is requested not asking us and not reporting. IFF_ALLMULTI is requested not asking us and not reporting.
*/ */
if ((flags ^ dev->gflags) & IFF_ALLMULTI) { if ((flags ^ dev->gflags) & IFF_ALLMULTI) {
int inc = (flags & IFF_ALLMULTI) ? +1 : -1; int inc = (flags & IFF_ALLMULTI) ? 1 : -1;
dev->gflags ^= IFF_ALLMULTI; dev->gflags ^= IFF_ALLMULTI;
dev_set_allmulti(dev, inc); dev_set_allmulti(dev, inc);
} }
...@@ -4165,6 +4191,7 @@ int dev_change_flags(struct net_device *dev, unsigned flags) ...@@ -4165,6 +4191,7 @@ int dev_change_flags(struct net_device *dev, unsigned flags)
return ret; return ret;
} }
EXPORT_SYMBOL(dev_change_flags);
/** /**
* dev_set_mtu - Change maximum transfer unit * dev_set_mtu - Change maximum transfer unit
...@@ -4198,6 +4225,7 @@ int dev_set_mtu(struct net_device *dev, int new_mtu) ...@@ -4198,6 +4225,7 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
call_netdevice_notifiers(NETDEV_CHANGEMTU, dev); call_netdevice_notifiers(NETDEV_CHANGEMTU, dev);
return err; return err;
} }
EXPORT_SYMBOL(dev_set_mtu);
/** /**
* dev_set_mac_address - Change Media Access Control Address * dev_set_mac_address - Change Media Access Control Address
...@@ -4222,6 +4250,7 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa) ...@@ -4222,6 +4250,7 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa)
call_netdevice_notifiers(NETDEV_CHANGEADDR, dev); call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
return err; return err;
} }
EXPORT_SYMBOL(dev_set_mac_address);
/* /*
* Perform the SIOCxIFxxx calls, inside read_lock(dev_base_lock) * Perform the SIOCxIFxxx calls, inside read_lock(dev_base_lock)
...@@ -4235,56 +4264,56 @@ static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cm ...@@ -4235,56 +4264,56 @@ static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cm
return -ENODEV; return -ENODEV;
switch (cmd) { switch (cmd) {
case SIOCGIFFLAGS: /* Get interface flags */ case SIOCGIFFLAGS: /* Get interface flags */
ifr->ifr_flags = (short) dev_get_flags(dev); ifr->ifr_flags = (short) dev_get_flags(dev);
return 0; return 0;
case SIOCGIFMETRIC: /* Get the metric on the interface case SIOCGIFMETRIC: /* Get the metric on the interface
(currently unused) */ (currently unused) */
ifr->ifr_metric = 0; ifr->ifr_metric = 0;
return 0; return 0;
case SIOCGIFMTU: /* Get the MTU of a device */ case SIOCGIFMTU: /* Get the MTU of a device */
ifr->ifr_mtu = dev->mtu; ifr->ifr_mtu = dev->mtu;
return 0; return 0;
case SIOCGIFHWADDR: case SIOCGIFHWADDR:
if (!dev->addr_len) if (!dev->addr_len)
memset(ifr->ifr_hwaddr.sa_data, 0, sizeof ifr->ifr_hwaddr.sa_data); memset(ifr->ifr_hwaddr.sa_data, 0, sizeof ifr->ifr_hwaddr.sa_data);
else else
memcpy(ifr->ifr_hwaddr.sa_data, dev->dev_addr, memcpy(ifr->ifr_hwaddr.sa_data, dev->dev_addr,
min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) dev->addr_len)); min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) dev->addr_len));
ifr->ifr_hwaddr.sa_family = dev->type; ifr->ifr_hwaddr.sa_family = dev->type;
return 0; return 0;
case SIOCGIFSLAVE: case SIOCGIFSLAVE:
err = -EINVAL; err = -EINVAL;
break; break;
case SIOCGIFMAP: case SIOCGIFMAP:
ifr->ifr_map.mem_start = dev->mem_start; ifr->ifr_map.mem_start = dev->mem_start;
ifr->ifr_map.mem_end = dev->mem_end; ifr->ifr_map.mem_end = dev->mem_end;
ifr->ifr_map.base_addr = dev->base_addr; ifr->ifr_map.base_addr = dev->base_addr;
ifr->ifr_map.irq = dev->irq; ifr->ifr_map.irq = dev->irq;
ifr->ifr_map.dma = dev->dma; ifr->ifr_map.dma = dev->dma;
ifr->ifr_map.port = dev->if_port; ifr->ifr_map.port = dev->if_port;
return 0; return 0;
case SIOCGIFINDEX: case SIOCGIFINDEX:
ifr->ifr_ifindex = dev->ifindex; ifr->ifr_ifindex = dev->ifindex;
return 0; return 0;
case SIOCGIFTXQLEN: case SIOCGIFTXQLEN:
ifr->ifr_qlen = dev->tx_queue_len; ifr->ifr_qlen = dev->tx_queue_len;
return 0; return 0;
default: default:
/* dev_ioctl() should ensure this case /* dev_ioctl() should ensure this case
* is never reached * is never reached
*/ */
WARN_ON(1); WARN_ON(1);
err = -EINVAL; err = -EINVAL;
break; break;
} }
return err; return err;
...@@ -4305,92 +4334,91 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd) ...@@ -4305,92 +4334,91 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
ops = dev->netdev_ops; ops = dev->netdev_ops;
switch (cmd) { switch (cmd) {
case SIOCSIFFLAGS: /* Set interface flags */ case SIOCSIFFLAGS: /* Set interface flags */
return dev_change_flags(dev, ifr->ifr_flags); return dev_change_flags(dev, ifr->ifr_flags);
case SIOCSIFMETRIC: /* Set the metric on the interface
(currently unused) */
return -EOPNOTSUPP;
case SIOCSIFMTU: /* Set the MTU of a device */
return dev_set_mtu(dev, ifr->ifr_mtu);
case SIOCSIFHWADDR: case SIOCSIFMETRIC: /* Set the metric on the interface
return dev_set_mac_address(dev, &ifr->ifr_hwaddr); (currently unused) */
return -EOPNOTSUPP;
case SIOCSIFHWBROADCAST: case SIOCSIFMTU: /* Set the MTU of a device */
if (ifr->ifr_hwaddr.sa_family != dev->type) return dev_set_mtu(dev, ifr->ifr_mtu);
return -EINVAL;
memcpy(dev->broadcast, ifr->ifr_hwaddr.sa_data,
min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) dev->addr_len));
call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
return 0;
case SIOCSIFMAP: case SIOCSIFHWADDR:
if (ops->ndo_set_config) { return dev_set_mac_address(dev, &ifr->ifr_hwaddr);
if (!netif_device_present(dev))
return -ENODEV;
return ops->ndo_set_config(dev, &ifr->ifr_map);
}
return -EOPNOTSUPP;
case SIOCADDMULTI: case SIOCSIFHWBROADCAST:
if ((!ops->ndo_set_multicast_list && !ops->ndo_set_rx_mode) || if (ifr->ifr_hwaddr.sa_family != dev->type)
ifr->ifr_hwaddr.sa_family != AF_UNSPEC) return -EINVAL;
return -EINVAL; memcpy(dev->broadcast, ifr->ifr_hwaddr.sa_data,
if (!netif_device_present(dev)) min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) dev->addr_len));
return -ENODEV; call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
return dev_mc_add(dev, ifr->ifr_hwaddr.sa_data, return 0;
dev->addr_len, 1);
case SIOCDELMULTI: case SIOCSIFMAP:
if ((!ops->ndo_set_multicast_list && !ops->ndo_set_rx_mode) || if (ops->ndo_set_config) {
ifr->ifr_hwaddr.sa_family != AF_UNSPEC)
return -EINVAL;
if (!netif_device_present(dev)) if (!netif_device_present(dev))
return -ENODEV; return -ENODEV;
return dev_mc_delete(dev, ifr->ifr_hwaddr.sa_data, return ops->ndo_set_config(dev, &ifr->ifr_map);
dev->addr_len, 1); }
return -EOPNOTSUPP;
case SIOCSIFTXQLEN: case SIOCADDMULTI:
if (ifr->ifr_qlen < 0) if ((!ops->ndo_set_multicast_list && !ops->ndo_set_rx_mode) ||
return -EINVAL; ifr->ifr_hwaddr.sa_family != AF_UNSPEC)
dev->tx_queue_len = ifr->ifr_qlen; return -EINVAL;
return 0; if (!netif_device_present(dev))
return -ENODEV;
return dev_mc_add(dev, ifr->ifr_hwaddr.sa_data,
dev->addr_len, 1);
case SIOCDELMULTI:
if ((!ops->ndo_set_multicast_list && !ops->ndo_set_rx_mode) ||
ifr->ifr_hwaddr.sa_family != AF_UNSPEC)
return -EINVAL;
if (!netif_device_present(dev))
return -ENODEV;
return dev_mc_delete(dev, ifr->ifr_hwaddr.sa_data,
dev->addr_len, 1);
case SIOCSIFNAME: case SIOCSIFTXQLEN:
ifr->ifr_newname[IFNAMSIZ-1] = '\0'; if (ifr->ifr_qlen < 0)
return dev_change_name(dev, ifr->ifr_newname); return -EINVAL;
dev->tx_queue_len = ifr->ifr_qlen;
return 0;
/* case SIOCSIFNAME:
* Unknown or private ioctl ifr->ifr_newname[IFNAMSIZ-1] = '\0';
*/ return dev_change_name(dev, ifr->ifr_newname);
default: /*
if ((cmd >= SIOCDEVPRIVATE && * Unknown or private ioctl
cmd <= SIOCDEVPRIVATE + 15) || */
cmd == SIOCBONDENSLAVE || default:
cmd == SIOCBONDRELEASE || if ((cmd >= SIOCDEVPRIVATE &&
cmd == SIOCBONDSETHWADDR || cmd <= SIOCDEVPRIVATE + 15) ||
cmd == SIOCBONDSLAVEINFOQUERY || cmd == SIOCBONDENSLAVE ||
cmd == SIOCBONDINFOQUERY || cmd == SIOCBONDRELEASE ||
cmd == SIOCBONDCHANGEACTIVE || cmd == SIOCBONDSETHWADDR ||
cmd == SIOCGMIIPHY || cmd == SIOCBONDSLAVEINFOQUERY ||
cmd == SIOCGMIIREG || cmd == SIOCBONDINFOQUERY ||
cmd == SIOCSMIIREG || cmd == SIOCBONDCHANGEACTIVE ||
cmd == SIOCBRADDIF || cmd == SIOCGMIIPHY ||
cmd == SIOCBRDELIF || cmd == SIOCGMIIREG ||
cmd == SIOCSHWTSTAMP || cmd == SIOCSMIIREG ||
cmd == SIOCWANDEV) { cmd == SIOCBRADDIF ||
err = -EOPNOTSUPP; cmd == SIOCBRDELIF ||
if (ops->ndo_do_ioctl) { cmd == SIOCSHWTSTAMP ||
if (netif_device_present(dev)) cmd == SIOCWANDEV) {
err = ops->ndo_do_ioctl(dev, ifr, cmd); err = -EOPNOTSUPP;
else if (ops->ndo_do_ioctl) {
err = -ENODEV; if (netif_device_present(dev))
} err = ops->ndo_do_ioctl(dev, ifr, cmd);
} else else
err = -EINVAL; err = -ENODEV;
}
} else
err = -EINVAL;
} }
return err; return err;
...@@ -4447,135 +4475,135 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg) ...@@ -4447,135 +4475,135 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
*/ */
switch (cmd) { switch (cmd) {
/* /*
* These ioctl calls: * These ioctl calls:
* - can be done by all. * - can be done by all.
* - atomic and do not require locking. * - atomic and do not require locking.
* - return a value * - return a value
*/ */
case SIOCGIFFLAGS: case SIOCGIFFLAGS:
case SIOCGIFMETRIC: case SIOCGIFMETRIC:
case SIOCGIFMTU: case SIOCGIFMTU:
case SIOCGIFHWADDR: case SIOCGIFHWADDR:
case SIOCGIFSLAVE: case SIOCGIFSLAVE:
case SIOCGIFMAP: case SIOCGIFMAP:
case SIOCGIFINDEX: case SIOCGIFINDEX:
case SIOCGIFTXQLEN: case SIOCGIFTXQLEN:
dev_load(net, ifr.ifr_name); dev_load(net, ifr.ifr_name);
read_lock(&dev_base_lock); read_lock(&dev_base_lock);
ret = dev_ifsioc_locked(net, &ifr, cmd); ret = dev_ifsioc_locked(net, &ifr, cmd);
read_unlock(&dev_base_lock); read_unlock(&dev_base_lock);
if (!ret) { if (!ret) {
if (colon) if (colon)
*colon = ':'; *colon = ':';
if (copy_to_user(arg, &ifr, if (copy_to_user(arg, &ifr,
sizeof(struct ifreq))) sizeof(struct ifreq)))
ret = -EFAULT; ret = -EFAULT;
} }
return ret; return ret;
case SIOCETHTOOL: case SIOCETHTOOL:
dev_load(net, ifr.ifr_name); dev_load(net, ifr.ifr_name);
rtnl_lock(); rtnl_lock();
ret = dev_ethtool(net, &ifr); ret = dev_ethtool(net, &ifr);
rtnl_unlock(); rtnl_unlock();
if (!ret) { if (!ret) {
if (colon) if (colon)
*colon = ':'; *colon = ':';
if (copy_to_user(arg, &ifr, if (copy_to_user(arg, &ifr,
sizeof(struct ifreq))) sizeof(struct ifreq)))
ret = -EFAULT; ret = -EFAULT;
} }
return ret; return ret;
/* /*
* These ioctl calls: * These ioctl calls:
* - require superuser power. * - require superuser power.
* - require strict serialization. * - require strict serialization.
* - return a value * - return a value
*/ */
case SIOCGMIIPHY: case SIOCGMIIPHY:
case SIOCGMIIREG: case SIOCGMIIREG:
case SIOCSIFNAME: case SIOCSIFNAME:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EPERM; return -EPERM;
dev_load(net, ifr.ifr_name); dev_load(net, ifr.ifr_name);
rtnl_lock(); rtnl_lock();
ret = dev_ifsioc(net, &ifr, cmd); ret = dev_ifsioc(net, &ifr, cmd);
rtnl_unlock(); rtnl_unlock();
if (!ret) { if (!ret) {
if (colon) if (colon)
*colon = ':'; *colon = ':';
if (copy_to_user(arg, &ifr, if (copy_to_user(arg, &ifr,
sizeof(struct ifreq))) sizeof(struct ifreq)))
ret = -EFAULT; ret = -EFAULT;
} }
return ret; return ret;
/* /*
* These ioctl calls: * These ioctl calls:
* - require superuser power. * - require superuser power.
* - require strict serialization. * - require strict serialization.
* - do not return a value * - do not return a value
*/ */
case SIOCSIFFLAGS: case SIOCSIFFLAGS:
case SIOCSIFMETRIC: case SIOCSIFMETRIC:
case SIOCSIFMTU: case SIOCSIFMTU:
case SIOCSIFMAP: case SIOCSIFMAP:
case SIOCSIFHWADDR: case SIOCSIFHWADDR:
case SIOCSIFSLAVE: case SIOCSIFSLAVE:
case SIOCADDMULTI: case SIOCADDMULTI:
case SIOCDELMULTI: case SIOCDELMULTI:
case SIOCSIFHWBROADCAST: case SIOCSIFHWBROADCAST:
case SIOCSIFTXQLEN: case SIOCSIFTXQLEN:
case SIOCSMIIREG: case SIOCSMIIREG:
case SIOCBONDENSLAVE: case SIOCBONDENSLAVE:
case SIOCBONDRELEASE: case SIOCBONDRELEASE:
case SIOCBONDSETHWADDR: case SIOCBONDSETHWADDR:
case SIOCBONDCHANGEACTIVE: case SIOCBONDCHANGEACTIVE:
case SIOCBRADDIF: case SIOCBRADDIF:
case SIOCBRDELIF: case SIOCBRDELIF:
case SIOCSHWTSTAMP: case SIOCSHWTSTAMP:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EPERM; return -EPERM;
/* fall through */ /* fall through */
case SIOCBONDSLAVEINFOQUERY: case SIOCBONDSLAVEINFOQUERY:
case SIOCBONDINFOQUERY: case SIOCBONDINFOQUERY:
dev_load(net, ifr.ifr_name);
rtnl_lock();
ret = dev_ifsioc(net, &ifr, cmd);
rtnl_unlock();
return ret;
case SIOCGIFMEM:
/* Get the per device memory space. We can add this but
* currently do not support it */
case SIOCSIFMEM:
/* Set the per device memory buffer space.
* Not applicable in our case */
case SIOCSIFLINK:
return -EINVAL;
/*
* Unknown or private ioctl.
*/
default:
if (cmd == SIOCWANDEV ||
(cmd >= SIOCDEVPRIVATE &&
cmd <= SIOCDEVPRIVATE + 15)) {
dev_load(net, ifr.ifr_name); dev_load(net, ifr.ifr_name);
rtnl_lock(); rtnl_lock();
ret = dev_ifsioc(net, &ifr, cmd); ret = dev_ifsioc(net, &ifr, cmd);
rtnl_unlock(); rtnl_unlock();
if (!ret && copy_to_user(arg, &ifr,
sizeof(struct ifreq)))
ret = -EFAULT;
return ret; return ret;
}
case SIOCGIFMEM: /* Take care of Wireless Extensions */
/* Get the per device memory space. We can add this but if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST)
* currently do not support it */ return wext_handle_ioctl(net, &ifr, cmd, arg);
case SIOCSIFMEM: return -EINVAL;
/* Set the per device memory buffer space.
* Not applicable in our case */
case SIOCSIFLINK:
return -EINVAL;
/*
* Unknown or private ioctl.
*/
default:
if (cmd == SIOCWANDEV ||
(cmd >= SIOCDEVPRIVATE &&
cmd <= SIOCDEVPRIVATE + 15)) {
dev_load(net, ifr.ifr_name);
rtnl_lock();
ret = dev_ifsioc(net, &ifr, cmd);
rtnl_unlock();
if (!ret && copy_to_user(arg, &ifr,
sizeof(struct ifreq)))
ret = -EFAULT;
return ret;
}
/* Take care of Wireless Extensions */
if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST)
return wext_handle_ioctl(net, &ifr, cmd, arg);
return -EINVAL;
} }
} }
...@@ -4840,6 +4868,7 @@ int register_netdevice(struct net_device *dev) ...@@ -4840,6 +4868,7 @@ int register_netdevice(struct net_device *dev)
dev->netdev_ops->ndo_uninit(dev); dev->netdev_ops->ndo_uninit(dev);
goto out; goto out;
} }
EXPORT_SYMBOL(register_netdevice);
/** /**
* init_dummy_netdev - init a dummy network device for NAPI * init_dummy_netdev - init a dummy network device for NAPI
...@@ -5126,6 +5155,8 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name, ...@@ -5126,6 +5155,8 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
} }
dev = PTR_ALIGN(p, NETDEV_ALIGN); dev = PTR_ALIGN(p, NETDEV_ALIGN);
pr_err("%s dev=%p queue_count=%d tx=%p\n", name, dev, queue_count, tx);
WARN_ON(queue_count == 1);
dev->padded = (char *)dev - (char *)p; dev->padded = (char *)dev - (char *)p;
if (dev_addr_init(dev)) if (dev_addr_init(dev))
...@@ -5192,6 +5223,7 @@ void free_netdev(struct net_device *dev) ...@@ -5192,6 +5223,7 @@ void free_netdev(struct net_device *dev)
/* will free via device release */ /* will free via device release */
put_device(&dev->dev); put_device(&dev->dev);
} }
EXPORT_SYMBOL(free_netdev);
/** /**
* synchronize_net - Synchronize with packet receive processing * synchronize_net - Synchronize with packet receive processing
...@@ -5204,6 +5236,7 @@ void synchronize_net(void) ...@@ -5204,6 +5236,7 @@ void synchronize_net(void)
might_sleep(); might_sleep();
synchronize_rcu(); synchronize_rcu();
} }
EXPORT_SYMBOL(synchronize_net);
/** /**
* unregister_netdevice - remove device from the kernel * unregister_netdevice - remove device from the kernel
...@@ -5224,6 +5257,7 @@ void unregister_netdevice(struct net_device *dev) ...@@ -5224,6 +5257,7 @@ void unregister_netdevice(struct net_device *dev)
/* Finish processing unregister after unlock */ /* Finish processing unregister after unlock */
net_set_todo(dev); net_set_todo(dev);
} }
EXPORT_SYMBOL(unregister_netdevice);
/** /**
* unregister_netdev - remove device from the kernel * unregister_netdev - remove device from the kernel
...@@ -5242,7 +5276,6 @@ void unregister_netdev(struct net_device *dev) ...@@ -5242,7 +5276,6 @@ void unregister_netdev(struct net_device *dev)
unregister_netdevice(dev); unregister_netdevice(dev);
rtnl_unlock(); rtnl_unlock();
} }
EXPORT_SYMBOL(unregister_netdev); EXPORT_SYMBOL(unregister_netdev);
/** /**
...@@ -5432,7 +5465,7 @@ unsigned long netdev_increment_features(unsigned long all, unsigned long one, ...@@ -5432,7 +5465,7 @@ unsigned long netdev_increment_features(unsigned long all, unsigned long one,
unsigned long mask) unsigned long mask)
{ {
/* If device needs checksumming, downgrade to it. */ /* If device needs checksumming, downgrade to it. */
if (all & NETIF_F_NO_CSUM && !(one & NETIF_F_NO_CSUM)) if (all & NETIF_F_NO_CSUM && !(one & NETIF_F_NO_CSUM))
all ^= NETIF_F_NO_CSUM | (one & NETIF_F_ALL_CSUM); all ^= NETIF_F_NO_CSUM | (one & NETIF_F_ALL_CSUM);
else if (mask & NETIF_F_ALL_CSUM) { else if (mask & NETIF_F_ALL_CSUM) {
/* If one device supports v4/v6 checksumming, set for all. */ /* If one device supports v4/v6 checksumming, set for all. */
...@@ -5658,41 +5691,3 @@ static int __init initialize_hashrnd(void) ...@@ -5658,41 +5691,3 @@ static int __init initialize_hashrnd(void)
late_initcall_sync(initialize_hashrnd); late_initcall_sync(initialize_hashrnd);
EXPORT_SYMBOL(__dev_get_by_index);
EXPORT_SYMBOL(__dev_get_by_name);
EXPORT_SYMBOL(__dev_remove_pack);
EXPORT_SYMBOL(dev_valid_name);
EXPORT_SYMBOL(dev_add_pack);
EXPORT_SYMBOL(dev_alloc_name);
EXPORT_SYMBOL(dev_close);
EXPORT_SYMBOL(dev_get_by_flags);
EXPORT_SYMBOL(dev_get_by_index);
EXPORT_SYMBOL(dev_get_by_name);
EXPORT_SYMBOL(dev_open);
EXPORT_SYMBOL(dev_queue_xmit);
EXPORT_SYMBOL(dev_remove_pack);
EXPORT_SYMBOL(dev_set_allmulti);
EXPORT_SYMBOL(dev_set_promiscuity);
EXPORT_SYMBOL(dev_change_flags);
EXPORT_SYMBOL(dev_set_mtu);
EXPORT_SYMBOL(dev_set_mac_address);
EXPORT_SYMBOL(free_netdev);
EXPORT_SYMBOL(netdev_boot_setup_check);
EXPORT_SYMBOL(netdev_set_master);
EXPORT_SYMBOL(netdev_state_change);
EXPORT_SYMBOL(netif_receive_skb);
EXPORT_SYMBOL(netif_rx);
EXPORT_SYMBOL(register_gifconf);
EXPORT_SYMBOL(register_netdevice);
EXPORT_SYMBOL(register_netdevice_notifier);
EXPORT_SYMBOL(skb_checksum_help);
EXPORT_SYMBOL(synchronize_net);
EXPORT_SYMBOL(unregister_netdevice);
EXPORT_SYMBOL(unregister_netdevice_notifier);
EXPORT_SYMBOL(net_enable_timestamp);
EXPORT_SYMBOL(net_disable_timestamp);
EXPORT_SYMBOL(dev_get_flags);
EXPORT_SYMBOL(dev_load);
EXPORT_PER_CPU_SYMBOL(softnet_data);
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