diff options
author | Patrick McHardy <kaber@trash.net> | 2007-07-11 22:42:31 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-07-11 22:45:36 -0400 |
commit | 0e06877c6fdbc67b1132be895f995acd1ff30135 (patch) | |
tree | ddaba8cddc8a95d23ee18f812c6aba67dd9b1c6f /drivers/net | |
parent | 2d85cba2b272a5201a60966a65a4f8c0bcc0bb71 (diff) |
[RTNETLINK]: rtnl_link: allow specifying initial device address
Drivers need to validate the initial addresses in their netlink attribute
validation function or manually reject them if they can't support this.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/dummy.c | 12 | ||||
-rw-r--r-- | drivers/net/ifb.c | 12 |
2 files changed, 24 insertions, 0 deletions
diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c index 373ff700404f..756a6bcb038d 100644 --- a/drivers/net/dummy.c +++ b/drivers/net/dummy.c | |||
@@ -84,9 +84,21 @@ static int dummy_xmit(struct sk_buff *skb, struct net_device *dev) | |||
84 | return 0; | 84 | return 0; |
85 | } | 85 | } |
86 | 86 | ||
87 | static int dummy_validate(struct nlattr *tb[], struct nlattr *data[]) | ||
88 | { | ||
89 | if (tb[IFLA_ADDRESS]) { | ||
90 | if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) | ||
91 | return -EINVAL; | ||
92 | if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS]))) | ||
93 | return -EADDRNOTAVAIL; | ||
94 | } | ||
95 | return 0; | ||
96 | } | ||
97 | |||
87 | static struct rtnl_link_ops dummy_link_ops __read_mostly = { | 98 | static struct rtnl_link_ops dummy_link_ops __read_mostly = { |
88 | .kind = "dummy", | 99 | .kind = "dummy", |
89 | .setup = dummy_setup, | 100 | .setup = dummy_setup, |
101 | .validate = dummy_validate, | ||
90 | }; | 102 | }; |
91 | 103 | ||
92 | /* Number of dummy devices to be set up by this module. */ | 104 | /* Number of dummy devices to be set up by this module. */ |
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c index c8e7c8f6ba3e..f5c3598e59af 100644 --- a/drivers/net/ifb.c +++ b/drivers/net/ifb.c | |||
@@ -221,10 +221,22 @@ static int ifb_open(struct net_device *dev) | |||
221 | return 0; | 221 | return 0; |
222 | } | 222 | } |
223 | 223 | ||
224 | static int ifb_validate(struct nlattr *tb[], struct nlattr *data[]) | ||
225 | { | ||
226 | if (tb[IFLA_ADDRESS]) { | ||
227 | if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) | ||
228 | return -EINVAL; | ||
229 | if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS]))) | ||
230 | return -EADDRNOTAVAIL; | ||
231 | } | ||
232 | return 0; | ||
233 | } | ||
234 | |||
224 | static struct rtnl_link_ops ifb_link_ops __read_mostly = { | 235 | static struct rtnl_link_ops ifb_link_ops __read_mostly = { |
225 | .kind = "ifb", | 236 | .kind = "ifb", |
226 | .priv_size = sizeof(struct ifb_private), | 237 | .priv_size = sizeof(struct ifb_private), |
227 | .setup = ifb_setup, | 238 | .setup = ifb_setup, |
239 | .validate = ifb_validate, | ||
228 | }; | 240 | }; |
229 | 241 | ||
230 | /* Number of ifb devices to be set up by this module. */ | 242 | /* Number of ifb devices to be set up by this module. */ |