Skip to content

Commit

Permalink
net: pass info struct via netdevice notifier
Browse files Browse the repository at this point in the history
So far, only net_device * could be passed along with netdevice notifier
event. This patch provides a possibility to pass custom structure
able to provide info that event listener needs to know.

Signed-off-by: Jiri Pirko <[email protected]>

v2->v3: fix typo on simeth
	shortened dev_getter
	shortened notifier_info struct name
v1->v2: fix notifier_call parameter in call_netdevice_notifier()
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jpirko authored and davem330 committed May 28, 2013
1 parent b1098bb commit 351638e
Show file tree
Hide file tree
Showing 80 changed files with 172 additions and 127 deletions.
2 changes: 1 addition & 1 deletion arch/ia64/hp/sim/simeth.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static __inline__ int dev_is_ethdev(struct net_device *dev)
static int
simeth_device_event(struct notifier_block *this,unsigned long event, void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct simeth_local *local;
struct in_device *in_dev;
struct in_ifaddr **ifap = NULL;
Expand Down
3 changes: 2 additions & 1 deletion arch/mips/txx9/generic/setup_tx4939.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ static int tx4939_netdev_event(struct notifier_block *this,
unsigned long event,
void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);

if (event == NETDEV_CHANGE && netif_carrier_ok(dev)) {
__u64 bit = 0;
if (dev->irq == TXX9_IRQ_BASE + TX4939_IR_ETH(0))
Expand Down
4 changes: 2 additions & 2 deletions drivers/infiniband/core/cma.c
Original file line number Diff line number Diff line change
Expand Up @@ -3269,9 +3269,9 @@ static int cma_netdev_change(struct net_device *ndev, struct rdma_id_private *id
}

static int cma_netdev_callback(struct notifier_block *self, unsigned long event,
void *ctx)
void *ptr)
{
struct net_device *ndev = (struct net_device *)ctx;
struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
struct cma_device *cma_dev;
struct rdma_id_private *id_priv;
int ret = NOTIFY_DONE;
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/hw/mlx4/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ static void netdev_removed(struct mlx4_ib_dev *dev, int port)
static int mlx4_ib_netdev_event(struct notifier_block *this, unsigned long event,
void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct mlx4_ib_dev *ibdev;
struct net_device *oldnd;
struct mlx4_ib_iboe *iboe;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3277,7 +3277,7 @@ static int bond_slave_netdev_event(unsigned long event,
static int bond_netdev_event(struct notifier_block *this,
unsigned long event, void *ptr)
{
struct net_device *event_dev = (struct net_device *)ptr;
struct net_device *event_dev = netdev_notifier_info_to_dev(ptr);

pr_debug("event_dev: %s, event: %lx\n",
event_dev ? event_dev->name : "None",
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/can/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ EXPORT_SYMBOL_GPL(devm_can_led_init);

/* NETDEV rename notifier to rename the associated led triggers too */
static int can_led_notifier(struct notifier_block *nb, unsigned long msg,
void *data)
void *ptr)
{
struct net_device *netdev = data;
struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
struct can_priv *priv = safe_candev_priv(netdev);
char name[CAN_LED_NAME_SZ];

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/broadcom/cnic.c
Original file line number Diff line number Diff line change
Expand Up @@ -5622,7 +5622,7 @@ static void cnic_rcv_netevent(struct cnic_local *cp, unsigned long event,
static int cnic_netdev_event(struct notifier_block *this, unsigned long event,
void *ptr)
{
struct net_device *netdev = ptr;
struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
struct cnic_dev *dev;
int new_dev = 0;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/marvell/skge.c
Original file line number Diff line number Diff line change
Expand Up @@ -3706,7 +3706,7 @@ static const struct file_operations skge_debug_fops = {
static int skge_device_event(struct notifier_block *unused,
unsigned long event, void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct skge_port *skge;
struct dentry *d;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/marvell/sky2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4642,7 +4642,7 @@ static const struct file_operations sky2_debug_fops = {
static int sky2_device_event(struct notifier_block *unused,
unsigned long event, void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct sky2_port *sky2 = netdev_priv(dev);

if (dev->netdev_ops->ndo_open != sky2_open || !sky2_debug)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3311,7 +3311,7 @@ static int netxen_netdev_event(struct notifier_block *this,
unsigned long event, void *ptr)
{
struct netxen_adapter *adapter;
struct net_device *dev = (struct net_device *)ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct net_device *orig_dev = dev;
struct net_device *slave;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3530,7 +3530,7 @@ static int qlcnic_netdev_event(struct notifier_block *this,
unsigned long event, void *ptr)
{
struct qlcnic_adapter *adapter;
struct net_device *dev = (struct net_device *)ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);

recheck:
if (dev == NULL)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/sfc/efx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2120,7 +2120,7 @@ static void efx_update_name(struct efx_nic *efx)
static int efx_netdev_event(struct notifier_block *this,
unsigned long event, void *ptr)
{
struct net_device *net_dev = ptr;
struct net_device *net_dev = netdev_notifier_info_to_dev(ptr);

if (net_dev->netdev_ops == &efx_netdev_ops &&
event == NETDEV_CHANGENAME)
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/hamradio/bpqether.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static struct packet_type bpq_packet_type __read_mostly = {
};

static struct notifier_block bpq_dev_notifier = {
.notifier_call =bpq_device_event,
.notifier_call = bpq_device_event,
};


Expand Down Expand Up @@ -544,9 +544,10 @@ static void bpq_free_device(struct net_device *ndev)
/*
* Handle device status changes.
*/
static int bpq_device_event(struct notifier_block *this,unsigned long event, void *ptr)
static int bpq_device_event(struct notifier_block *this,
unsigned long event, void *ptr)
{
struct net_device *dev = (struct net_device *)ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);

if (!net_eq(dev_net(dev), &init_net))
return NOTIFY_DONE;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/macvlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ static struct rtnl_link_ops macvlan_link_ops = {
static int macvlan_device_event(struct notifier_block *unused,
unsigned long event, void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct macvlan_dev *vlan, *next;
struct macvlan_port *port;
LIST_HEAD(list_kill);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/macvtap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ EXPORT_SYMBOL_GPL(macvtap_get_socket);
static int macvtap_device_event(struct notifier_block *unused,
unsigned long event, void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct macvlan_dev *vlan;
struct device *classdev;
dev_t devt;
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/netconsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,12 +653,11 @@ static struct configfs_subsystem netconsole_subsys = {

/* Handle network interface device notifications */
static int netconsole_netdev_event(struct notifier_block *this,
unsigned long event,
void *ptr)
unsigned long event, void *ptr)
{
unsigned long flags;
struct netconsole_target *nt;
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
bool stopped = false;

if (!(event == NETDEV_CHANGENAME || event == NETDEV_UNREGISTER ||
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ppp/pppoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static void pppoe_flush_dev(struct net_device *dev)
static int pppoe_device_event(struct notifier_block *this,
unsigned long event, void *ptr)
{
struct net_device *dev = (struct net_device *)ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);

/* Only look at sockets that are using this specific device. */
switch (event) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/team/team.c
Original file line number Diff line number Diff line change
Expand Up @@ -2647,7 +2647,7 @@ static void team_port_change_check(struct team_port *port, bool linkup)
static int team_device_event(struct notifier_block *unused,
unsigned long event, void *ptr)
{
struct net_device *dev = (struct net_device *) ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct team_port *port;

port = team_port_get_rtnl(dev);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wan/dlci.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ static void dlci_setup(struct net_device *dev)
static int dlci_dev_event(struct notifier_block *unused,
unsigned long event, void *ptr)
{
struct net_device *dev = (struct net_device *) ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);

if (dev_net(dev) != &init_net)
return NOTIFY_DONE;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wan/hdlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static inline void hdlc_proto_stop(struct net_device *dev)
static int hdlc_device_event(struct notifier_block *this, unsigned long event,
void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
hdlc_device *hdlc;
unsigned long flags;
int on;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wan/lapbether.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ static int lapbeth_device_event(struct notifier_block *this,
unsigned long event, void *ptr)
{
struct lapbethdev *lapbeth;
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);

if (dev_net(dev) != &init_net)
return NOTIFY_DONE;
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/fcoe/fcoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,7 @@ static int fcoe_device_notification(struct notifier_block *notifier,
{
struct fcoe_ctlr_device *cdev;
struct fc_lport *lport = NULL;
struct net_device *netdev = ptr;
struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
struct fcoe_ctlr *ctlr;
struct fcoe_interface *fcoe;
struct fcoe_port *port;
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/fcoe/fcoe_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ static struct net_device *fcoe_if_to_netdev(const char *buffer)
static int libfcoe_device_notification(struct notifier_block *notifier,
ulong event, void *ptr)
{
struct net_device *netdev = ptr;
struct net_device *netdev = netdev_notifier_info_to_dev(ptr);

switch (event) {
case NETDEV_UNREGISTER:
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/csr/netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2891,7 +2891,7 @@ void uf_net_get_name(struct net_device *dev, char *name, int len)
*/
static int
uf_netdev_event(struct notifier_block *notif, unsigned long event, void* ptr) {
struct net_device *netdev = ptr;
struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(netdev);
unifi_priv_t *priv = NULL;
static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static const struct file_operations ft1000_proc_fops = {
static int ft1000NotifyProc(struct notifier_block *this, unsigned long event,
void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct ft1000_info *info;

info = netdev_priv(dev);
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/ft1000/ft1000-usb/ft1000_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static const struct file_operations ft1000_proc_fops = {
static int
ft1000NotifyProc(struct notifier_block *this, unsigned long event, void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct ft1000_info *info;
struct proc_dir_entry *ft1000_proc_file;

Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/silicom/bpctl_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static unsigned long str_to_hex(char *p);
static int bp_device_event(struct notifier_block *unused,
unsigned long event, void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
static bpctl_dev_t *pbpctl_dev = NULL, *pbpctl_dev_m = NULL;
int dev_num = 0, ret = 0, ret_d = 0, time_left = 0;
/* printk("BP_PROC_SUPPORT event =%d %s %d\n", event,dev->name, dev->ifindex ); */
Expand Down
13 changes: 13 additions & 0 deletions include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,19 @@ struct packet_offload {

extern int register_netdevice_notifier(struct notifier_block *nb);
extern int unregister_netdevice_notifier(struct notifier_block *nb);

struct netdev_notifier_info {
struct net_device *dev;
};

static inline struct net_device *
netdev_notifier_info_to_dev(const struct netdev_notifier_info *info)
{
return info->dev;
}

extern int call_netdevice_notifiers_info(unsigned long val, struct net_device *dev,
struct netdev_notifier_info *info);
extern int call_netdevice_notifiers(unsigned long val, struct net_device *dev);


Expand Down
2 changes: 1 addition & 1 deletion net/8021q/vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ static void __vlan_device_event(struct net_device *dev, unsigned long event)
static int vlan_device_event(struct notifier_block *unused, unsigned long event,
void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct vlan_group *grp;
struct vlan_info *vlan_info;
int i, flgs;
Expand Down
2 changes: 1 addition & 1 deletion net/appletalk/aarp.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ static void aarp_expire_timeout(unsigned long unused)
static int aarp_device_event(struct notifier_block *this, unsigned long event,
void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
int ct;

if (!net_eq(dev_net(dev), &init_net))
Expand Down
2 changes: 1 addition & 1 deletion net/appletalk/ddp.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ static inline void atalk_dev_down(struct net_device *dev)
static int ddp_device_event(struct notifier_block *this, unsigned long event,
void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);

if (!net_eq(dev_net(dev), &init_net))
return NOTIFY_DONE;
Expand Down
4 changes: 2 additions & 2 deletions net/atm/clip.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,9 @@ static int clip_create(int number)
}

static int clip_device_event(struct notifier_block *this, unsigned long event,
void *arg)
void *ptr)
{
struct net_device *dev = arg;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);

if (!net_eq(dev_net(dev), &init_net))
return NOTIFY_DONE;
Expand Down
6 changes: 2 additions & 4 deletions net/atm/mpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,14 +998,12 @@ int msg_to_mpoad(struct k_message *mesg, struct mpoa_client *mpc)
}

static int mpoa_event_listener(struct notifier_block *mpoa_notifier,
unsigned long event, void *dev_ptr)
unsigned long event, void *ptr)
{
struct net_device *dev;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct mpoa_client *mpc;
struct lec_priv *priv;

dev = dev_ptr;

if (!net_eq(dev_net(dev), &init_net))
return NOTIFY_DONE;

Expand Down
6 changes: 3 additions & 3 deletions net/ax25/af_ax25.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ static void ax25_kill_by_device(struct net_device *dev)
* Handle device status changes.
*/
static int ax25_device_event(struct notifier_block *this, unsigned long event,
void *ptr)
void *ptr)
{
struct net_device *dev = (struct net_device *)ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);

if (!net_eq(dev_net(dev), &init_net))
return NOTIFY_DONE;
Expand Down Expand Up @@ -1974,7 +1974,7 @@ static struct packet_type ax25_packet_type __read_mostly = {
};

static struct notifier_block ax25_dev_notifier = {
.notifier_call =ax25_device_event,
.notifier_call = ax25_device_event,
};

static int __init ax25_init(void)
Expand Down
2 changes: 1 addition & 1 deletion net/batman-adv/hard-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ void batadv_hardif_remove_interfaces(void)
static int batadv_hard_if_event(struct notifier_block *this,
unsigned long event, void *ptr)
{
struct net_device *net_dev = ptr;
struct net_device *net_dev = netdev_notifier_info_to_dev(ptr);
struct batadv_hard_iface *hard_iface;
struct batadv_hard_iface *primary_if = NULL;
struct batadv_priv *bat_priv;
Expand Down
2 changes: 1 addition & 1 deletion net/bridge/br_notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct notifier_block br_device_notifier = {
*/
static int br_device_event(struct notifier_block *unused, unsigned long event, void *ptr)
{
struct net_device *dev = ptr;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct net_bridge_port *p;
struct net_bridge *br;
bool changed_addr;
Expand Down
4 changes: 2 additions & 2 deletions net/caif/caif_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ EXPORT_SYMBOL(caif_enroll_dev);

/* notify Caif of device events */
static int caif_device_notify(struct notifier_block *me, unsigned long what,
void *arg)
void *ptr)
{
struct net_device *dev = arg;
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct caif_device_entry *caifd = NULL;
struct caif_dev_common *caifdev;
struct cfcnfg *cfg;
Expand Down
Loading

0 comments on commit 351638e

Please sign in to comment.