diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2008-11-20 00:32:24 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-20 00:32:24 -0500 |
commit | d314774cf2cd5dfeb39a00d37deee65d4c627927 (patch) | |
tree | 1c7778b509cea814aa2b7115949667941037d07c /net/core/rtnetlink.c | |
parent | 6b41e7dd90c6a628ab5fb8d781302d60a243b2ce (diff) |
netdev: network device operations infrastructure
This patch changes the network device internal API to move adminstrative
operations out of the network device structure and into a separate structure.
This patch involves some hackery to maintain compatablity between the
new and old model, so all 300+ drivers don't have to be changed at once.
For drivers that aren't converted yet, the netdevice_ops virt function list
still resides in the net_device structure. For old protocols, the new
net_device_ops are copied out to the old net_device pointers.
After the transistion is completed the nag message can be changed to
an WARN_ON, and the compatiablity code can be made configurable.
Some function pointers aren't moved:
* destructor can't be in net_device_ops because
it may need to be referenced after the module is unloaded.
* neighbor setup is manipulated in a couple of places that need special
consideration
* hard_start_xmit is in the fast path for transmit.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/rtnetlink.c')
-rw-r--r-- | net/core/rtnetlink.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 4dfb6b4d4559..6f8e0778e565 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -762,6 +762,7 @@ static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[]) | |||
762 | static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, | 762 | static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, |
763 | struct nlattr **tb, char *ifname, int modified) | 763 | struct nlattr **tb, char *ifname, int modified) |
764 | { | 764 | { |
765 | const struct net_device_ops *ops = dev->netdev_ops; | ||
765 | int send_addr_notify = 0; | 766 | int send_addr_notify = 0; |
766 | int err; | 767 | int err; |
767 | 768 | ||
@@ -783,7 +784,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, | |||
783 | struct rtnl_link_ifmap *u_map; | 784 | struct rtnl_link_ifmap *u_map; |
784 | struct ifmap k_map; | 785 | struct ifmap k_map; |
785 | 786 | ||
786 | if (!dev->set_config) { | 787 | if (!ops->ndo_set_config) { |
787 | err = -EOPNOTSUPP; | 788 | err = -EOPNOTSUPP; |
788 | goto errout; | 789 | goto errout; |
789 | } | 790 | } |
@@ -801,7 +802,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, | |||
801 | k_map.dma = (unsigned char) u_map->dma; | 802 | k_map.dma = (unsigned char) u_map->dma; |
802 | k_map.port = (unsigned char) u_map->port; | 803 | k_map.port = (unsigned char) u_map->port; |
803 | 804 | ||
804 | err = dev->set_config(dev, &k_map); | 805 | err = ops->ndo_set_config(dev, &k_map); |
805 | if (err < 0) | 806 | if (err < 0) |
806 | goto errout; | 807 | goto errout; |
807 | 808 | ||
@@ -812,7 +813,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, | |||
812 | struct sockaddr *sa; | 813 | struct sockaddr *sa; |
813 | int len; | 814 | int len; |
814 | 815 | ||
815 | if (!dev->set_mac_address) { | 816 | if (!ops->ndo_set_mac_address) { |
816 | err = -EOPNOTSUPP; | 817 | err = -EOPNOTSUPP; |
817 | goto errout; | 818 | goto errout; |
818 | } | 819 | } |
@@ -831,7 +832,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, | |||
831 | sa->sa_family = dev->type; | 832 | sa->sa_family = dev->type; |
832 | memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]), | 833 | memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]), |
833 | dev->addr_len); | 834 | dev->addr_len); |
834 | err = dev->set_mac_address(dev, sa); | 835 | err = ops->ndo_set_mac_address(dev, sa); |
835 | kfree(sa); | 836 | kfree(sa); |
836 | if (err) | 837 | if (err) |
837 | goto errout; | 838 | goto errout; |