Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipmr: Use MAXVIFS in mroute_msgsize().

mroute_msgsize() calculates skb size needed for ipmr_fill_mroute().

The size differs based on mrt->maxvif.

We will drop RTNL for ipmr_rtm_getroute() and mrt->maxvif may
change under RCU.

To avoid -EMSGSIZE, let's calculate the size with the maximum
value of mrt->maxvif, MAXVIFS.

struct rtnexthop is 8 bytes and MAXVIFS is 32, so the maximum delta
is 256 bytes, which is small enough.

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260228221800.1082070-5-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
2bd6c9d6 402a8111

+4 -5
+4 -5
net/ipv4/ipmr.c
··· 2510 2510 cmd, flags); 2511 2511 } 2512 2512 2513 - static size_t mroute_msgsize(bool unresolved, int maxvif) 2513 + static size_t mroute_msgsize(bool unresolved) 2514 2514 { 2515 2515 size_t len = 2516 2516 NLMSG_ALIGN(sizeof(struct rtmsg)) ··· 2523 2523 len = len 2524 2524 + nla_total_size(4) /* RTA_IIF */ 2525 2525 + nla_total_size(0) /* RTA_MULTIPATH */ 2526 - + maxvif * NLA_ALIGN(sizeof(struct rtnexthop)) 2526 + + MAXVIFS * NLA_ALIGN(sizeof(struct rtnexthop)) 2527 2527 /* RTA_MFC_STATS */ 2528 2528 + nla_total_size_64bit(sizeof(struct rta_mfc_stats)) 2529 2529 ; ··· 2538 2538 struct sk_buff *skb; 2539 2539 int err = -ENOBUFS; 2540 2540 2541 - skb = nlmsg_new(mroute_msgsize(mfc->_c.mfc_parent >= MAXVIFS, 2542 - mrt->maxvif), 2541 + skb = nlmsg_new(mroute_msgsize(mfc->_c.mfc_parent >= MAXVIFS), 2543 2542 GFP_ATOMIC); 2544 2543 if (!skb) 2545 2544 goto errout; ··· 2710 2711 goto errout_free; 2711 2712 } 2712 2713 2713 - skb = nlmsg_new(mroute_msgsize(false, mrt->maxvif), GFP_KERNEL); 2714 + skb = nlmsg_new(mroute_msgsize(false), GFP_KERNEL); 2714 2715 if (!skb) { 2715 2716 err = -ENOBUFS; 2716 2717 goto errout_free;