mctp: emit RTM_NEWADDR and RTM_DELADDR
Matt Johnston
maintainerPATCH 1/1 mctp: emit RTM_NEWADDR and RTM_DELADDR
Userspace can receive notification of MCTP address changes via RTNLGRP_MCTP_IFADDR rtnetlink multicast group.
--- include/uapi/linux/rtnetlink.h | 2 ++ net/mctp/device.c | 55 ++++++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 5 deletions(-)
include/uapi/linux/rtnetlink.h +2 -0
@@ -754,6 +754,8 @@ enum rtnetlink_groups {#define RTNLGRP_NEXTHOP RTNLGRP_NEXTHOP RTNLGRP_BRVLAN,#define RTNLGRP_BRVLAN RTNLGRP_BRVLAN + RTNLGRP_MCTP_IFADDR, +#define RTNLGRP_MCTP_IFADDR RTNLGRP_MCTP_IFADDR __RTNLGRP_MAX };#define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
net/mctp/device.c +50 -5
91 lines not on this page · raw message
Signature · 1 line
2.32.0
Jeremy Kerr
maintainerHi Matt,
Quoted 2 lines
Userspace can receive notification of MCTP address changes via
RTNLGRP_MCTP_IFADDRrtnetlink multicast group.
Nice! A couple of minor things:
Quoted 2 lines
+static void mctp_addr_notify(struct
mctp_dev*mdev,mctp_eid_teid, intmsg_type, + structsk_buff*req_skb, struct nlmsghdr*req_nlh)
Is it worthwhile keeping the portid argument here, rather than the entire request skb? Might prevent some confusion with the notify skb.
(I'm OK if we settle on the req_skb approach too though, as it does save a little repeated code in call sites)
Quoted 5 lines
+{
+ int rc;
+ structsk_buff*skb;
+ struct net *net =dev_net(mdev->dev);
+ u32 portid = NETLINK_CB(req_skb).portid;
Super minor, but: reverse Christmas tree here (and above)?
Quoted 13 lines
net/mctp/device.c +13
-0+ + skb = nlmsg_new(mctp_addrinfo_size(), GFP_KERNEL); + if (!skb) { + rc = -ENOBUFS; + goto out; + } + + rc = mctp_fill_addrinfo(skb, mdev, eid, msg_type, + portid, req_nlh->nlmsg_seq, 0); + if (rc < 0) + goto out; + + rtnl_notify(skb, net, portid, RTNLGRP_MCTP_IFADDR, req_nlh,
Quoted 7 lines
GFP_KERNEL);
+out:
+ if (rc < 0) {
+ if (skb)
+ kfree_skb(skb);
+ rtnl_set_sk_err(net,RTNLGRP_MCTP_IFADDR, rc); + }
We don't need that if (skb) condition on the kfree_skb - Yang has removed a bunch in 5cfe53cfeb1. We could also remove the rc check if we use the goto-label only for errors. Maybe something like:
rtnl_notify(skb, net, portid, RTNLGRP_MCTP_IFADDR, req_nlh, GFP_KERNEL);
return;
err:
kfree_skb(skb);
rtnl_set_sk_err(net, RTNLGRP_MCTP_IFADDR, rc);
}Cheers,
Jeremy