Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 300773
b: refs/heads/master
c: 3ff661c
h: refs/heads/master
i:
  300771: c65ba4c
v: v3
  • Loading branch information
John Fastabend authored and David S. Miller committed Apr 15, 2012
1 parent 461d6e9 commit 8eed216
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d83b060360485454fcd6870340ec01d6f96f2295
refs/heads/master: 3ff661c38c8492a2859e39e0ea1e3b6d30e89bf5
35 changes: 33 additions & 2 deletions trunk/net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,33 @@ static int nlmsg_populate_fdb_fill(struct sk_buff *skb,
return -EMSGSIZE;
}

static inline size_t rtnl_fdb_nlmsg_size(void)
{
return NLMSG_ALIGN(sizeof(struct ndmsg)) + nla_total_size(ETH_ALEN);
}

static void rtnl_fdb_notify(struct net_device *dev, u8 *addr, int type)
{
struct net *net = dev_net(dev);
struct sk_buff *skb;
int err = -ENOBUFS;

skb = nlmsg_new(rtnl_fdb_nlmsg_size(), GFP_ATOMIC);
if (!skb)
goto errout;

err = nlmsg_populate_fdb_fill(skb, dev, addr, 0, 0, type, NTF_SELF);
if (err < 0) {
kfree_skb(skb);
goto errout;
}

rtnl_notify(skb, net, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC);
return;
errout:
rtnl_set_sk_err(net, RTNLGRP_NEIGH, err);
}

static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
{
struct net *net = sock_net(skb->sk);
Expand Down Expand Up @@ -2067,8 +2094,10 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
err = dev->netdev_ops->ndo_fdb_add(ndm, dev, addr,
nlh->nlmsg_flags);

if (!err)
if (!err) {
rtnl_fdb_notify(dev, addr, RTM_NEWNEIGH);
ndm->ndm_flags &= ~NTF_SELF;
}
}
out:
return err;
Expand Down Expand Up @@ -2125,8 +2154,10 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
if ((ndm->ndm_flags & NTF_SELF) && dev->netdev_ops->ndo_fdb_del) {
err = dev->netdev_ops->ndo_fdb_del(ndm, dev, addr);

if (!err)
if (!err) {
rtnl_fdb_notify(dev, addr, RTM_DELNEIGH);
ndm->ndm_flags &= ~NTF_SELF;
}
}
out:
return err;
Expand Down

0 comments on commit 8eed216

Please sign in to comment.