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.

net: ipv6: ip6mr: Split ip6mr_forward2() in two

Some of the work of ip6mr_forward2() is specific to IPMR forwarding, and
should not take place on the output path. In order to allow reuse of the
common parts, extract out of the function a helper,
ip6mr_prepare_forward().

Signed-off-by: Petr Machata <petrm@nvidia.com>
Link: https://patch.msgid.link/8932bd5c0fbe3f662b158803b8509604fa7bc113.1750113335.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Petr Machata and committed by
Jakub Kicinski
1b02f447 094f39d5

+16 -7
+16 -7
net/ipv6/ip6mr.c
··· 2035 2035 * Processing handlers for ip6mr_forward 2036 2036 */ 2037 2037 2038 - static void ip6mr_forward2(struct net *net, struct mr_table *mrt, 2039 - struct sk_buff *skb, int vifi) 2038 + static int ip6mr_prepare_xmit(struct net *net, struct mr_table *mrt, 2039 + struct sk_buff *skb, int vifi) 2040 2040 { 2041 2041 struct vif_device *vif = &mrt->vif_table[vifi]; 2042 - struct net_device *indev = skb->dev; 2043 2042 struct net_device *vif_dev; 2044 2043 struct ipv6hdr *ipv6h; 2045 2044 struct dst_entry *dst; ··· 2046 2047 2047 2048 vif_dev = vif_dev_read(vif); 2048 2049 if (!vif_dev) 2049 - goto out_free; 2050 + return -1; 2050 2051 2051 2052 #ifdef CONFIG_IPV6_PIMSM_V2 2052 2053 if (vif->flags & MIFF_REGISTER) { ··· 2055 2056 DEV_STATS_ADD(vif_dev, tx_bytes, skb->len); 2056 2057 DEV_STATS_INC(vif_dev, tx_packets); 2057 2058 ip6mr_cache_report(mrt, skb, vifi, MRT6MSG_WHOLEPKT); 2058 - goto out_free; 2059 + return -1; 2059 2060 } 2060 2061 #endif 2061 2062 ··· 2069 2070 dst = ip6_route_output(net, NULL, &fl6); 2070 2071 if (dst->error) { 2071 2072 dst_release(dst); 2072 - goto out_free; 2073 + return -1; 2073 2074 } 2074 2075 2075 2076 skb_dst_drop(skb); ··· 2093 2094 /* We are about to write */ 2094 2095 /* XXX: extension headers? */ 2095 2096 if (skb_cow(skb, sizeof(*ipv6h) + LL_RESERVED_SPACE(vif_dev))) 2096 - goto out_free; 2097 + return -1; 2097 2098 2098 2099 ipv6h = ipv6_hdr(skb); 2099 2100 ipv6h->hop_limit--; 2101 + return 0; 2102 + } 2103 + 2104 + static void ip6mr_forward2(struct net *net, struct mr_table *mrt, 2105 + struct sk_buff *skb, int vifi) 2106 + { 2107 + struct net_device *indev = skb->dev; 2108 + 2109 + if (ip6mr_prepare_xmit(net, mrt, skb, vifi)) 2110 + goto out_free; 2100 2111 2101 2112 IP6CB(skb)->flags |= IP6SKB_FORWARDED; 2102 2113