rtnetlink: pass netlink message header and portid to rtnl_configure_link()
This patch pass netlink message header and portid to rtnl_configure_link() All the functions in this call chain need to add the parameters so we can use them in the last call rtnl_notify(), and notify the userspace about the new link info if NLM_F_ECHO flag is set. - rtnl_configure_link() - __dev_notify_flags() - rtmsg_ifinfo() - rtmsg_ifinfo_event() - rtmsg_ifinfo_build_skb() - rtmsg_ifinfo_send() - rtnl_notify() Also move __dev_notify_flags() declaration to net/core/dev.h, as Jakub suggested. Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
37fe9b9816
commit
1d997f1013
@ -760,7 +760,7 @@ int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid)
|
||||
EXPORT_SYMBOL(rtnl_unicast);
|
||||
|
||||
void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group,
|
||||
struct nlmsghdr *nlh, gfp_t flags)
|
||||
const struct nlmsghdr *nlh, gfp_t flags)
|
||||
{
|
||||
struct sock *rtnl = net->rtnl;
|
||||
|
||||
@ -3180,7 +3180,8 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm)
|
||||
int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm,
|
||||
u32 portid, const struct nlmsghdr *nlh)
|
||||
{
|
||||
unsigned int old_flags;
|
||||
int err;
|
||||
@ -3194,10 +3195,10 @@ int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm)
|
||||
}
|
||||
|
||||
if (dev->rtnl_link_state == RTNL_LINK_INITIALIZED) {
|
||||
__dev_notify_flags(dev, old_flags, (old_flags ^ dev->flags));
|
||||
__dev_notify_flags(dev, old_flags, (old_flags ^ dev->flags), portid, nlh);
|
||||
} else {
|
||||
dev->rtnl_link_state = RTNL_LINK_INITIALIZED;
|
||||
__dev_notify_flags(dev, old_flags, ~0U);
|
||||
__dev_notify_flags(dev, old_flags, ~0U, portid, nlh);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -3369,7 +3370,7 @@ static int rtnl_newlink_create(struct sk_buff *skb, struct ifinfomsg *ifm,
|
||||
goto out;
|
||||
}
|
||||
|
||||
err = rtnl_configure_link(dev, ifm);
|
||||
err = rtnl_configure_link(dev, ifm, 0, NULL);
|
||||
if (err < 0)
|
||||
goto out_unregister;
|
||||
if (link_net) {
|
||||
@ -3896,7 +3897,7 @@ static int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
struct sk_buff *rtmsg_ifinfo_build_skb(int type, struct net_device *dev,
|
||||
unsigned int change,
|
||||
u32 event, gfp_t flags, int *new_nsid,
|
||||
int new_ifindex)
|
||||
int new_ifindex, u32 portid, u32 seq)
|
||||
{
|
||||
struct net *net = dev_net(dev);
|
||||
struct sk_buff *skb;
|
||||
@ -3907,7 +3908,7 @@ struct sk_buff *rtmsg_ifinfo_build_skb(int type, struct net_device *dev,
|
||||
goto errout;
|
||||
|
||||
err = rtnl_fill_ifinfo(skb, dev, dev_net(dev),
|
||||
type, 0, 0, change, 0, 0, event,
|
||||
type, portid, seq, change, 0, 0, event,
|
||||
new_nsid, new_ifindex, -1, flags);
|
||||
if (err < 0) {
|
||||
/* -EMSGSIZE implies BUG in if_nlmsg_size() */
|
||||
@ -3922,16 +3923,18 @@ errout:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void rtmsg_ifinfo_send(struct sk_buff *skb, struct net_device *dev, gfp_t flags)
|
||||
void rtmsg_ifinfo_send(struct sk_buff *skb, struct net_device *dev, gfp_t flags,
|
||||
u32 portid, const struct nlmsghdr *nlh)
|
||||
{
|
||||
struct net *net = dev_net(dev);
|
||||
|
||||
rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, flags);
|
||||
rtnl_notify(skb, net, portid, RTNLGRP_LINK, nlh, flags);
|
||||
}
|
||||
|
||||
static void rtmsg_ifinfo_event(int type, struct net_device *dev,
|
||||
unsigned int change, u32 event,
|
||||
gfp_t flags, int *new_nsid, int new_ifindex)
|
||||
gfp_t flags, int *new_nsid, int new_ifindex,
|
||||
u32 portid, const struct nlmsghdr *nlh)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
|
||||
@ -3939,23 +3942,23 @@ static void rtmsg_ifinfo_event(int type, struct net_device *dev,
|
||||
return;
|
||||
|
||||
skb = rtmsg_ifinfo_build_skb(type, dev, change, event, flags, new_nsid,
|
||||
new_ifindex);
|
||||
new_ifindex, portid, nlmsg_seq(nlh));
|
||||
if (skb)
|
||||
rtmsg_ifinfo_send(skb, dev, flags);
|
||||
rtmsg_ifinfo_send(skb, dev, flags, portid, nlh);
|
||||
}
|
||||
|
||||
void rtmsg_ifinfo(int type, struct net_device *dev, unsigned int change,
|
||||
gfp_t flags)
|
||||
gfp_t flags, u32 portid, const struct nlmsghdr *nlh)
|
||||
{
|
||||
rtmsg_ifinfo_event(type, dev, change, rtnl_get_event(0), flags,
|
||||
NULL, 0);
|
||||
NULL, 0, portid, nlh);
|
||||
}
|
||||
|
||||
void rtmsg_ifinfo_newnet(int type, struct net_device *dev, unsigned int change,
|
||||
gfp_t flags, int *new_nsid, int new_ifindex)
|
||||
{
|
||||
rtmsg_ifinfo_event(type, dev, change, rtnl_get_event(0), flags,
|
||||
new_nsid, new_ifindex);
|
||||
new_nsid, new_ifindex, 0, NULL);
|
||||
}
|
||||
|
||||
static int nlmsg_populate_fdb_fill(struct sk_buff *skb,
|
||||
@ -6140,7 +6143,7 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi
|
||||
case NETDEV_CHANGELOWERSTATE:
|
||||
case NETDEV_CHANGE_TX_QUEUE_LEN:
|
||||
rtmsg_ifinfo_event(RTM_NEWLINK, dev, 0, rtnl_get_event(event),
|
||||
GFP_KERNEL, NULL, 0);
|
||||
GFP_KERNEL, NULL, 0, 0, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
Reference in New Issue
Block a user