Skip to content

Commit 6b6e272

Browse files
stephen hemmingerdavem330
authored andcommitted
netdev: make address const in device address management
The internal functions for add/deleting addresses don't change their argument. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1d3ff76 commit 6b6e272

6 files changed

Lines changed: 44 additions & 42 deletions

File tree

‎drivers/net/ethernet/intel/ixgbe/ixgbe_main.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6890,7 +6890,7 @@ static int ixgbe_set_features(struct net_device *netdev,
68906890

68916891
static int ixgbe_ndo_fdb_add(struct ndmsg *ndm,
68926892
struct net_device *dev,
6893-
unsigned char *addr,
6893+
const unsigned char *addr,
68946894
u16 flags)
68956895
{
68966896
struct ixgbe_adapter *adapter = netdev_priv(dev);
@@ -6927,7 +6927,7 @@ static int ixgbe_ndo_fdb_add(struct ndmsg *ndm,
69276927

69286928
static int ixgbe_ndo_fdb_del(struct ndmsg *ndm,
69296929
struct net_device *dev,
6930-
unsigned char *addr)
6930+
const unsigned char *addr)
69316931
{
69326932
struct ixgbe_adapter *adapter = netdev_priv(dev);
69336933
int err = -EOPNOTSUPP;

‎drivers/net/macvlan.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ static int macvlan_vlan_rx_kill_vid(struct net_device *dev,
548548

549549
static int macvlan_fdb_add(struct ndmsg *ndm,
550550
struct net_device *dev,
551-
unsigned char *addr,
551+
const unsigned char *addr,
552552
u16 flags)
553553
{
554554
struct macvlan_dev *vlan = netdev_priv(dev);
@@ -567,7 +567,7 @@ static int macvlan_fdb_add(struct ndmsg *ndm,
567567

568568
static int macvlan_fdb_del(struct ndmsg *ndm,
569569
struct net_device *dev,
570-
unsigned char *addr)
570+
const unsigned char *addr)
571571
{
572572
struct macvlan_dev *vlan = netdev_priv(dev);
573573
int err = -EINVAL;

‎include/linux/netdevice.h‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -907,10 +907,10 @@ struct netdev_fcoe_hbainfo {
907907
* Must return >0 or -errno if it changed dev->features itself.
908908
*
909909
* int (*ndo_fdb_add)(struct ndmsg *ndm, struct net_device *dev,
910-
* unsigned char *addr, u16 flags)
910+
* const unsigned char *addr, u16 flags)
911911
* Adds an FDB entry to dev for addr.
912912
* int (*ndo_fdb_del)(struct ndmsg *ndm, struct net_device *dev,
913-
* unsigned char *addr)
913+
* const unsigned char *addr)
914914
* Deletes the FDB entry from dev coresponding to addr.
915915
* int (*ndo_fdb_dump)(struct sk_buff *skb, struct netlink_callback *cb,
916916
* struct net_device *dev, int idx)
@@ -1017,11 +1017,11 @@ struct net_device_ops {
10171017

10181018
int (*ndo_fdb_add)(struct ndmsg *ndm,
10191019
struct net_device *dev,
1020-
unsigned char *addr,
1020+
const unsigned char *addr,
10211021
u16 flags);
10221022
int (*ndo_fdb_del)(struct ndmsg *ndm,
10231023
struct net_device *dev,
1024-
unsigned char *addr);
1024+
const unsigned char *addr);
10251025
int (*ndo_fdb_dump)(struct sk_buff *skb,
10261026
struct netlink_callback *cb,
10271027
struct net_device *dev,
@@ -2561,9 +2561,9 @@ extern void __hw_addr_flush(struct netdev_hw_addr_list *list);
25612561
extern void __hw_addr_init(struct netdev_hw_addr_list *list);
25622562

25632563
/* Functions used for device addresses handling */
2564-
extern int dev_addr_add(struct net_device *dev, unsigned char *addr,
2564+
extern int dev_addr_add(struct net_device *dev, const unsigned char *addr,
25652565
unsigned char addr_type);
2566-
extern int dev_addr_del(struct net_device *dev, unsigned char *addr,
2566+
extern int dev_addr_del(struct net_device *dev, const unsigned char *addr,
25672567
unsigned char addr_type);
25682568
extern int dev_addr_add_multiple(struct net_device *to_dev,
25692569
struct net_device *from_dev,
@@ -2575,20 +2575,20 @@ extern void dev_addr_flush(struct net_device *dev);
25752575
extern int dev_addr_init(struct net_device *dev);
25762576

25772577
/* Functions used for unicast addresses handling */
2578-
extern int dev_uc_add(struct net_device *dev, unsigned char *addr);
2579-
extern int dev_uc_add_excl(struct net_device *dev, unsigned char *addr);
2580-
extern int dev_uc_del(struct net_device *dev, unsigned char *addr);
2578+
extern int dev_uc_add(struct net_device *dev, const unsigned char *addr);
2579+
extern int dev_uc_add_excl(struct net_device *dev, const unsigned char *addr);
2580+
extern int dev_uc_del(struct net_device *dev, const unsigned char *addr);
25812581
extern int dev_uc_sync(struct net_device *to, struct net_device *from);
25822582
extern void dev_uc_unsync(struct net_device *to, struct net_device *from);
25832583
extern void dev_uc_flush(struct net_device *dev);
25842584
extern void dev_uc_init(struct net_device *dev);
25852585

25862586
/* Functions used for multicast addresses handling */
2587-
extern int dev_mc_add(struct net_device *dev, unsigned char *addr);
2588-
extern int dev_mc_add_global(struct net_device *dev, unsigned char *addr);
2589-
extern int dev_mc_add_excl(struct net_device *dev, unsigned char *addr);
2590-
extern int dev_mc_del(struct net_device *dev, unsigned char *addr);
2591-
extern int dev_mc_del_global(struct net_device *dev, unsigned char *addr);
2587+
extern int dev_mc_add(struct net_device *dev, const unsigned char *addr);
2588+
extern int dev_mc_add_global(struct net_device *dev, const unsigned char *addr);
2589+
extern int dev_mc_add_excl(struct net_device *dev, const unsigned char *addr);
2590+
extern int dev_mc_del(struct net_device *dev, const unsigned char *addr);
2591+
extern int dev_mc_del_global(struct net_device *dev, const unsigned char *addr);
25922592
extern int dev_mc_sync(struct net_device *to, struct net_device *from);
25932593
extern void dev_mc_unsync(struct net_device *to, struct net_device *from);
25942594
extern void dev_mc_flush(struct net_device *dev);

‎net/bridge/br_fdb.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ static int fdb_add_entry(struct net_bridge_port *source, const __u8 *addr,
609609

610610
/* Add new permanent fdb entry with RTM_NEWNEIGH */
611611
int br_fdb_add(struct ndmsg *ndm, struct net_device *dev,
612-
unsigned char *addr, u16 nlh_flags)
612+
const unsigned char *addr, u16 nlh_flags)
613613
{
614614
struct net_bridge_port *p;
615615
int err = 0;
@@ -639,7 +639,7 @@ int br_fdb_add(struct ndmsg *ndm, struct net_device *dev,
639639
return err;
640640
}
641641

642-
static int fdb_delete_by_addr(struct net_bridge_port *p, u8 *addr)
642+
static int fdb_delete_by_addr(struct net_bridge_port *p, const u8 *addr)
643643
{
644644
struct net_bridge *br = p->br;
645645
struct hlist_head *head = &br->hash[br_mac_hash(addr)];
@@ -655,7 +655,7 @@ static int fdb_delete_by_addr(struct net_bridge_port *p, u8 *addr)
655655

656656
/* Remove neighbor entry with RTM_DELNEIGH */
657657
int br_fdb_delete(struct ndmsg *ndm, struct net_device *dev,
658-
unsigned char *addr)
658+
const unsigned char *addr)
659659
{
660660
struct net_bridge_port *p;
661661
int err;

‎net/bridge/br_private.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,10 @@ extern void br_fdb_update(struct net_bridge *br,
363363

364364
extern int br_fdb_delete(struct ndmsg *ndm,
365365
struct net_device *dev,
366-
unsigned char *addr);
366+
const unsigned char *addr);
367367
extern int br_fdb_add(struct ndmsg *nlh,
368368
struct net_device *dev,
369-
unsigned char *addr,
369+
const unsigned char *addr,
370370
u16 nlh_flags);
371371
extern int br_fdb_dump(struct sk_buff *skb,
372372
struct netlink_callback *cb,

‎net/core/dev_addr_lists.c‎

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323

2424
static int __hw_addr_create_ex(struct netdev_hw_addr_list *list,
25-
unsigned char *addr, int addr_len,
25+
const unsigned char *addr, int addr_len,
2626
unsigned char addr_type, bool global)
2727
{
2828
struct netdev_hw_addr *ha;
@@ -46,7 +46,7 @@ static int __hw_addr_create_ex(struct netdev_hw_addr_list *list,
4646
}
4747

4848
static int __hw_addr_add_ex(struct netdev_hw_addr_list *list,
49-
unsigned char *addr, int addr_len,
49+
const unsigned char *addr, int addr_len,
5050
unsigned char addr_type, bool global)
5151
{
5252
struct netdev_hw_addr *ha;
@@ -72,14 +72,15 @@ static int __hw_addr_add_ex(struct netdev_hw_addr_list *list,
7272
return __hw_addr_create_ex(list, addr, addr_len, addr_type, global);
7373
}
7474

75-
static int __hw_addr_add(struct netdev_hw_addr_list *list, unsigned char *addr,
76-
int addr_len, unsigned char addr_type)
75+
static int __hw_addr_add(struct netdev_hw_addr_list *list,
76+
const unsigned char *addr, int addr_len,
77+
unsigned char addr_type)
7778
{
7879
return __hw_addr_add_ex(list, addr, addr_len, addr_type, false);
7980
}
8081

8182
static int __hw_addr_del_ex(struct netdev_hw_addr_list *list,
82-
unsigned char *addr, int addr_len,
83+
const unsigned char *addr, int addr_len,
8384
unsigned char addr_type, bool global)
8485
{
8586
struct netdev_hw_addr *ha;
@@ -104,8 +105,9 @@ static int __hw_addr_del_ex(struct netdev_hw_addr_list *list,
104105
return -ENOENT;
105106
}
106107

107-
static int __hw_addr_del(struct netdev_hw_addr_list *list, unsigned char *addr,
108-
int addr_len, unsigned char addr_type)
108+
static int __hw_addr_del(struct netdev_hw_addr_list *list,
109+
const unsigned char *addr, int addr_len,
110+
unsigned char addr_type)
109111
{
110112
return __hw_addr_del_ex(list, addr, addr_len, addr_type, false);
111113
}
@@ -278,7 +280,7 @@ EXPORT_SYMBOL(dev_addr_init);
278280
*
279281
* The caller must hold the rtnl_mutex.
280282
*/
281-
int dev_addr_add(struct net_device *dev, unsigned char *addr,
283+
int dev_addr_add(struct net_device *dev, const unsigned char *addr,
282284
unsigned char addr_type)
283285
{
284286
int err;
@@ -303,7 +305,7 @@ EXPORT_SYMBOL(dev_addr_add);
303305
*
304306
* The caller must hold the rtnl_mutex.
305307
*/
306-
int dev_addr_del(struct net_device *dev, unsigned char *addr,
308+
int dev_addr_del(struct net_device *dev, const unsigned char *addr,
307309
unsigned char addr_type)
308310
{
309311
int err;
@@ -390,7 +392,7 @@ EXPORT_SYMBOL(dev_addr_del_multiple);
390392
* @dev: device
391393
* @addr: address to add
392394
*/
393-
int dev_uc_add_excl(struct net_device *dev, unsigned char *addr)
395+
int dev_uc_add_excl(struct net_device *dev, const unsigned char *addr)
394396
{
395397
struct netdev_hw_addr *ha;
396398
int err;
@@ -421,7 +423,7 @@ EXPORT_SYMBOL(dev_uc_add_excl);
421423
* Add a secondary unicast address to the device or increase
422424
* the reference count if it already exists.
423425
*/
424-
int dev_uc_add(struct net_device *dev, unsigned char *addr)
426+
int dev_uc_add(struct net_device *dev, const unsigned char *addr)
425427
{
426428
int err;
427429

@@ -443,7 +445,7 @@ EXPORT_SYMBOL(dev_uc_add);
443445
* Release reference to a secondary unicast address and remove it
444446
* from the device if the reference count drops to zero.
445447
*/
446-
int dev_uc_del(struct net_device *dev, unsigned char *addr)
448+
int dev_uc_del(struct net_device *dev, const unsigned char *addr)
447449
{
448450
int err;
449451

@@ -543,7 +545,7 @@ EXPORT_SYMBOL(dev_uc_init);
543545
* @dev: device
544546
* @addr: address to add
545547
*/
546-
int dev_mc_add_excl(struct net_device *dev, unsigned char *addr)
548+
int dev_mc_add_excl(struct net_device *dev, const unsigned char *addr)
547549
{
548550
struct netdev_hw_addr *ha;
549551
int err;
@@ -566,7 +568,7 @@ int dev_mc_add_excl(struct net_device *dev, unsigned char *addr)
566568
}
567569
EXPORT_SYMBOL(dev_mc_add_excl);
568570

569-
static int __dev_mc_add(struct net_device *dev, unsigned char *addr,
571+
static int __dev_mc_add(struct net_device *dev, const unsigned char *addr,
570572
bool global)
571573
{
572574
int err;
@@ -587,7 +589,7 @@ static int __dev_mc_add(struct net_device *dev, unsigned char *addr,
587589
* Add a multicast address to the device or increase
588590
* the reference count if it already exists.
589591
*/
590-
int dev_mc_add(struct net_device *dev, unsigned char *addr)
592+
int dev_mc_add(struct net_device *dev, const unsigned char *addr)
591593
{
592594
return __dev_mc_add(dev, addr, false);
593595
}
@@ -600,13 +602,13 @@ EXPORT_SYMBOL(dev_mc_add);
600602
*
601603
* Add a global multicast address to the device.
602604
*/
603-
int dev_mc_add_global(struct net_device *dev, unsigned char *addr)
605+
int dev_mc_add_global(struct net_device *dev, const unsigned char *addr)
604606
{
605607
return __dev_mc_add(dev, addr, true);
606608
}
607609
EXPORT_SYMBOL(dev_mc_add_global);
608610

609-
static int __dev_mc_del(struct net_device *dev, unsigned char *addr,
611+
static int __dev_mc_del(struct net_device *dev, const unsigned char *addr,
610612
bool global)
611613
{
612614
int err;
@@ -628,7 +630,7 @@ static int __dev_mc_del(struct net_device *dev, unsigned char *addr,
628630
* Release reference to a multicast address and remove it
629631
* from the device if the reference count drops to zero.
630632
*/
631-
int dev_mc_del(struct net_device *dev, unsigned char *addr)
633+
int dev_mc_del(struct net_device *dev, const unsigned char *addr)
632634
{
633635
return __dev_mc_del(dev, addr, false);
634636
}
@@ -642,7 +644,7 @@ EXPORT_SYMBOL(dev_mc_del);
642644
* Release reference to a multicast address and remove it
643645
* from the device if the reference count drops to zero.
644646
*/
645-
int dev_mc_del_global(struct net_device *dev, unsigned char *addr)
647+
int dev_mc_del_global(struct net_device *dev, const unsigned char *addr)
646648
{
647649
return __dev_mc_del(dev, addr, true);
648650
}

0 commit comments

Comments
 (0)