Skip to contentSkip to conversation

mctp: emit RTM_NEWADDR and RTM_DELADDR

PATCH Superseded Matt Johnston 2 participants 2 messages Dec 15, 2021

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Matt Johnston

author maintainer
#0 lore raw

PATCH 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
index 5888492a5257..93d934cc4613 100644
@@ -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
maintainer
#1 lore raw

Hi Matt,

Quoted 2 lines

Userspace can receive notification of MCTP address changes via RTNLGRP_MCTP_IFADDR rtnetlink multicast group.

Nice! A couple of minor things:

Quoted 2 lines

+static void mctp_addr_notify(struct mctp_dev *mdev, mctp_eid_t eid, int msg_type, +                            struct sk_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;
+       struct sk_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