~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to net/bridge/br_netlink.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
#include <linux/kernel.h>
14
14
#include <linux/slab.h>
 
15
#include <linux/etherdevice.h>
15
16
#include <net/rtnetlink.h>
16
17
#include <net/net_namespace.h>
17
18
#include <net/sock.h>
 
19
 
18
20
#include "br_private.h"
19
21
 
20
22
static inline size_t br_nlmsg_size(void)
118
120
        int idx;
119
121
 
120
122
        idx = 0;
121
 
        for_each_netdev(net, dev) {
122
 
                struct net_bridge_port *port = br_port_get_rtnl(dev);
 
123
        rcu_read_lock();
 
124
        for_each_netdev_rcu(net, dev) {
 
125
                struct net_bridge_port *port = br_port_get_rcu(dev);
123
126
 
124
127
                /* not a bridge port */
125
128
                if (!port || idx < cb->args[0])
133
136
skip:
134
137
                ++idx;
135
138
        }
136
 
 
 
139
        rcu_read_unlock();
137
140
        cb->args[0] = idx;
138
141
 
139
142
        return skb->len;
188
191
        return 0;
189
192
}
190
193
 
 
194
static int br_validate(struct nlattr *tb[], struct nlattr *data[])
 
195
{
 
196
        if (tb[IFLA_ADDRESS]) {
 
197
                if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
 
198
                        return -EINVAL;
 
199
                if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS])))
 
200
                        return -EADDRNOTAVAIL;
 
201
        }
 
202
 
 
203
        return 0;
 
204
}
 
205
 
 
206
static struct rtnl_link_ops br_link_ops __read_mostly = {
 
207
        .kind           = "bridge",
 
208
        .priv_size      = sizeof(struct net_bridge),
 
209
        .setup          = br_dev_setup,
 
210
        .validate       = br_validate,
 
211
};
191
212
 
192
213
int __init br_netlink_init(void)
193
214
{
194
 
        if (__rtnl_register(PF_BRIDGE, RTM_GETLINK, NULL, br_dump_ifinfo))
195
 
                return -ENOBUFS;
196
 
 
197
 
        /* Only the first call to __rtnl_register can fail */
198
 
        __rtnl_register(PF_BRIDGE, RTM_SETLINK, br_rtm_setlink, NULL);
 
215
        int err;
 
216
 
 
217
        err = rtnl_link_register(&br_link_ops);
 
218
        if (err < 0)
 
219
                goto err1;
 
220
 
 
221
        err = __rtnl_register(PF_BRIDGE, RTM_GETLINK, NULL, br_dump_ifinfo);
 
222
        if (err)
 
223
                goto err2;
 
224
        err = __rtnl_register(PF_BRIDGE, RTM_SETLINK, br_rtm_setlink, NULL);
 
225
        if (err)
 
226
                goto err3;
 
227
        err = __rtnl_register(PF_BRIDGE, RTM_NEWNEIGH, br_fdb_add, NULL);
 
228
        if (err)
 
229
                goto err3;
 
230
        err = __rtnl_register(PF_BRIDGE, RTM_DELNEIGH, br_fdb_delete, NULL);
 
231
        if (err)
 
232
                goto err3;
 
233
        err = __rtnl_register(PF_BRIDGE, RTM_GETNEIGH, NULL, br_fdb_dump);
 
234
        if (err)
 
235
                goto err3;
199
236
 
200
237
        return 0;
 
238
 
 
239
err3:
 
240
        rtnl_unregister_all(PF_BRIDGE);
 
241
err2:
 
242
        rtnl_link_unregister(&br_link_ops);
 
243
err1:
 
244
        return err;
201
245
}
202
246
 
203
247
void __exit br_netlink_fini(void)
204
248
{
 
249
        rtnl_link_unregister(&br_link_ops);
205
250
        rtnl_unregister_all(PF_BRIDGE);
206
251
}
207