Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH net-next v2] mctp: Specify route types, require rtm_type in RTM_*ROUTE messages
@ 2021-08-10 2:38 Jeremy Kerr
2021-08-11 23:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Jeremy Kerr @ 2021-08-10 2:38 UTC (permalink / raw)
To: netdev; +Cc: Matt Johnston, David S. Miller, Jakub Kicinski
This change adds a 'type' attribute to routes, which can be parsed from
a RTM_NEWROUTE message. This will help to distinguish local vs. peer
routes in a future change.
This means userspace will need to set a correct rtm_type in RTM_NEWROUTE
and RTM_DELROUTE messages; we currently only accept RTN_UNICAST.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
---
v2:
- specify net-next as base branch
---
include/net/mctp.h | 1 +
net/mctp/route.c | 27 ++++++++++++++++++++++-----
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/include/net/mctp.h b/include/net/mctp.h
index 54bbe042c973..a824d47c3c6d 100644
--- a/include/net/mctp.h
+++ b/include/net/mctp.h
@@ -173,6 +173,7 @@ struct mctp_route {
struct mctp_dev *dev;
unsigned int mtu;
+ unsigned char type;
int (*output)(struct mctp_route *route,
struct sk_buff *skb);
diff --git a/net/mctp/route.c b/net/mctp/route.c
index 960c85039eae..fc77337f4870 100644
--- a/net/mctp/route.c
+++ b/net/mctp/route.c
@@ -710,8 +710,9 @@ int mctp_local_output(struct sock *sk, struct mctp_route *rt,
/* route management */
static int mctp_route_add(struct mctp_dev *mdev, mctp_eid_t daddr_start,
unsigned int daddr_extent, unsigned int mtu,
- bool is_local)
+ unsigned char type)
{
+ int (*rtfn)(struct mctp_route *rt, struct sk_buff *skb);
struct net *net = dev_net(mdev->dev);
struct mctp_route *rt, *ert;
@@ -721,6 +722,17 @@ static int mctp_route_add(struct mctp_dev *mdev, mctp_eid_t daddr_start,
if (daddr_extent > 0xff || daddr_start + daddr_extent >= 255)
return -EINVAL;
+ switch (type) {
+ case RTN_LOCAL:
+ rtfn = mctp_route_input;
+ break;
+ case RTN_UNICAST:
+ rtfn = mctp_route_output;
+ break;
+ default:
+ return -EINVAL;
+ }
+
rt = mctp_route_alloc();
if (!rt)
return -ENOMEM;
@@ -730,7 +742,8 @@ static int mctp_route_add(struct mctp_dev *mdev, mctp_eid_t daddr_start,
rt->mtu = mtu;
rt->dev = mdev;
dev_hold(rt->dev->dev);
- rt->output = is_local ? mctp_route_input : mctp_route_output;
+ rt->type = type;
+ rt->output = rtfn;
ASSERT_RTNL();
/* Prevent duplicate identical routes. */
@@ -777,7 +790,7 @@ static int mctp_route_remove(struct mctp_dev *mdev, mctp_eid_t daddr_start,
int mctp_route_add_local(struct mctp_dev *mdev, mctp_eid_t addr)
{
- return mctp_route_add(mdev, addr, 0, 0, true);
+ return mctp_route_add(mdev, addr, 0, 0, RTN_LOCAL);
}
int mctp_route_remove_local(struct mctp_dev *mdev, mctp_eid_t addr)
@@ -939,7 +952,11 @@ static int mctp_newroute(struct sk_buff *skb, struct nlmsghdr *nlh,
/* TODO: parse mtu from nlparse */
mtu = 0;
- rc = mctp_route_add(mdev, daddr_start, rtm->rtm_dst_len, mtu, false);
+ if (rtm->rtm_type != RTN_UNICAST)
+ return -EINVAL;
+
+ rc = mctp_route_add(mdev, daddr_start, rtm->rtm_dst_len, mtu,
+ rtm->rtm_type);
return rc;
}
@@ -988,7 +1005,7 @@ static int mctp_fill_rtinfo(struct sk_buff *skb, struct mctp_route *rt,
hdr->rtm_table = RT_TABLE_DEFAULT;
hdr->rtm_protocol = RTPROT_STATIC; /* everything is user-defined */
hdr->rtm_scope = RT_SCOPE_LINK; /* TODO: scope in mctp_route? */
- hdr->rtm_type = RTN_ANYCAST; /* TODO: type from route */
+ hdr->rtm_type = rt->type;
if (nla_put_u8(skb, RTA_DST, rt->min))
goto cancel;
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH net-next v2] mctp: Specify route types, require rtm_type in RTM_*ROUTE messages
2021-08-10 2:38 [PATCH net-next v2] mctp: Specify route types, require rtm_type in RTM_*ROUTE messages Jeremy Kerr
@ 2021-08-11 23:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-08-11 23:20 UTC (permalink / raw)
To: Jeremy Kerr; +Cc: netdev, matt, davem, kuba
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
On Tue, 10 Aug 2021 10:38:34 +0800 you wrote:
> This change adds a 'type' attribute to routes, which can be parsed from
> a RTM_NEWROUTE message. This will help to distinguish local vs. peer
> routes in a future change.
>
> This means userspace will need to set a correct rtm_type in RTM_NEWROUTE
> and RTM_DELROUTE messages; we currently only accept RTN_UNICAST.
>
> [...]
Here is the summary with links:
- [net-next,v2] mctp: Specify route types, require rtm_type in RTM_*ROUTE messages
https://git.kernel.org/netdev/net-next/c/83f0a0b7285b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-11 23:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-10 2:38 [PATCH net-next v2] mctp: Specify route types, require rtm_type in RTM_*ROUTE messages Jeremy Kerr
2021-08-11 23:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).