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

net: dst: remove unnecessary input parameter in dst_alloc and dst_init

Since commit 1202cdd66531("Remove DECnet support from kernel") has been
merged, all callers pass in the initial_ref value of 1 when they call
dst_alloc(). Therefore, remove initial_ref when the dst_alloc() is
declared and replace initial_ref with 1 in dst_alloc().
Also when all callers call dst_init(), the value of initial_ref is 1.
Therefore, remove the input parameter initial_ref of the dst_init() and
replace initial_ref with the value 1 in dst_init.

Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Link: https://lore.kernel.org/r/20230911125045.346390-1-shaozhengchao@huawei.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Zhengchao Shao and committed by
Paolo Abeni
762c8dc7 be3af13f

+17 -17
+2 -2
include/net/dst.h
··· 392 392 { 393 393 return dst_discard_out(&init_net, skb->sk, skb); 394 394 } 395 - void *dst_alloc(struct dst_ops *ops, struct net_device *dev, int initial_ref, 395 + void *dst_alloc(struct dst_ops *ops, struct net_device *dev, 396 396 int initial_obsolete, unsigned short flags); 397 397 void dst_init(struct dst_entry *dst, struct dst_ops *ops, 398 - struct net_device *dev, int initial_ref, int initial_obsolete, 398 + struct net_device *dev, int initial_obsolete, 399 399 unsigned short flags); 400 400 struct dst_entry *dst_destroy(struct dst_entry *dst); 401 401 void dst_dev_put(struct dst_entry *dst);
+5 -5
net/core/dst.c
··· 45 45 EXPORT_SYMBOL(dst_default_metrics); 46 46 47 47 void dst_init(struct dst_entry *dst, struct dst_ops *ops, 48 - struct net_device *dev, int initial_ref, int initial_obsolete, 48 + struct net_device *dev, int initial_obsolete, 49 49 unsigned short flags) 50 50 { 51 51 dst->dev = dev; ··· 66 66 dst->tclassid = 0; 67 67 #endif 68 68 dst->lwtstate = NULL; 69 - rcuref_init(&dst->__rcuref, initial_ref); 69 + rcuref_init(&dst->__rcuref, 1); 70 70 INIT_LIST_HEAD(&dst->rt_uncached); 71 71 dst->__use = 0; 72 72 dst->lastuse = jiffies; ··· 77 77 EXPORT_SYMBOL(dst_init); 78 78 79 79 void *dst_alloc(struct dst_ops *ops, struct net_device *dev, 80 - int initial_ref, int initial_obsolete, unsigned short flags) 80 + int initial_obsolete, unsigned short flags) 81 81 { 82 82 struct dst_entry *dst; 83 83 ··· 90 90 if (!dst) 91 91 return NULL; 92 92 93 - dst_init(dst, ops, dev, initial_ref, initial_obsolete, flags); 93 + dst_init(dst, ops, dev, initial_obsolete, flags); 94 94 95 95 return dst; 96 96 } ··· 270 270 struct dst_entry *dst; 271 271 272 272 dst = &md_dst->dst; 273 - dst_init(dst, &dst_blackhole_ops, NULL, 1, DST_OBSOLETE_NONE, 273 + dst_init(dst, &dst_blackhole_ops, NULL, DST_OBSOLETE_NONE, 274 274 DST_METADATA | DST_NOCOUNT); 275 275 memset(dst + 1, 0, sizeof(*md_dst) + optslen - sizeof(*dst)); 276 276 md_dst->type = type;
+3 -3
net/ipv4/route.c
··· 1630 1630 { 1631 1631 struct rtable *rt; 1632 1632 1633 - rt = dst_alloc(&ipv4_dst_ops, dev, 1, DST_OBSOLETE_FORCE_CHK, 1633 + rt = dst_alloc(&ipv4_dst_ops, dev, DST_OBSOLETE_FORCE_CHK, 1634 1634 (noxfrm ? DST_NOXFRM : 0)); 1635 1635 1636 1636 if (rt) { ··· 1658 1658 { 1659 1659 struct rtable *new_rt; 1660 1660 1661 - new_rt = dst_alloc(&ipv4_dst_ops, dev, 1, DST_OBSOLETE_FORCE_CHK, 1661 + new_rt = dst_alloc(&ipv4_dst_ops, dev, DST_OBSOLETE_FORCE_CHK, 1662 1662 rt->dst.flags); 1663 1663 1664 1664 if (new_rt) { ··· 2832 2832 struct rtable *ort = (struct rtable *) dst_orig; 2833 2833 struct rtable *rt; 2834 2834 2835 - rt = dst_alloc(&ipv4_dst_blackhole_ops, NULL, 1, DST_OBSOLETE_DEAD, 0); 2835 + rt = dst_alloc(&ipv4_dst_blackhole_ops, NULL, DST_OBSOLETE_DEAD, 0); 2836 2836 if (rt) { 2837 2837 struct dst_entry *new = &rt->dst; 2838 2838
+2 -2
net/ipv6/route.c
··· 341 341 int flags) 342 342 { 343 343 struct rt6_info *rt = dst_alloc(&net->ipv6.ip6_dst_ops, dev, 344 - 1, DST_OBSOLETE_FORCE_CHK, flags); 344 + DST_OBSOLETE_FORCE_CHK, flags); 345 345 346 346 if (rt) { 347 347 rt6_info_init(rt); ··· 2655 2655 struct net_device *loopback_dev = net->loopback_dev; 2656 2656 struct dst_entry *new = NULL; 2657 2657 2658 - rt = dst_alloc(&ip6_dst_blackhole_ops, loopback_dev, 1, 2658 + rt = dst_alloc(&ip6_dst_blackhole_ops, loopback_dev, 2659 2659 DST_OBSOLETE_DEAD, 0); 2660 2660 if (rt) { 2661 2661 rt6_info_init(rt);
+2 -2
net/openvswitch/actions.c
··· 873 873 874 874 prepare_frag(vport, skb, orig_network_offset, 875 875 ovs_key_mac_proto(key)); 876 - dst_init(&ovs_rt.dst, &ovs_dst_ops, NULL, 1, 876 + dst_init(&ovs_rt.dst, &ovs_dst_ops, NULL, 877 877 DST_OBSOLETE_NONE, DST_NOCOUNT); 878 878 ovs_rt.dst.dev = vport->dev; 879 879 ··· 890 890 prepare_frag(vport, skb, orig_network_offset, 891 891 ovs_key_mac_proto(key)); 892 892 memset(&ovs_rt, 0, sizeof(ovs_rt)); 893 - dst_init(&ovs_rt.dst, &ovs_dst_ops, NULL, 1, 893 + dst_init(&ovs_rt.dst, &ovs_dst_ops, NULL, 894 894 DST_OBSOLETE_NONE, DST_NOCOUNT); 895 895 ovs_rt.dst.dev = vport->dev; 896 896
+2 -2
net/sched/sch_frag.c
··· 96 96 unsigned long orig_dst; 97 97 98 98 sch_frag_prepare_frag(skb, xmit); 99 - dst_init(&sch_frag_rt.dst, &sch_frag_dst_ops, NULL, 1, 99 + dst_init(&sch_frag_rt.dst, &sch_frag_dst_ops, NULL, 100 100 DST_OBSOLETE_NONE, DST_NOCOUNT); 101 101 sch_frag_rt.dst.dev = skb->dev; 102 102 ··· 112 112 113 113 sch_frag_prepare_frag(skb, xmit); 114 114 memset(&sch_frag_rt, 0, sizeof(sch_frag_rt)); 115 - dst_init(&sch_frag_rt.dst, &sch_frag_dst_ops, NULL, 1, 115 + dst_init(&sch_frag_rt.dst, &sch_frag_dst_ops, NULL, 116 116 DST_OBSOLETE_NONE, DST_NOCOUNT); 117 117 sch_frag_rt.dst.dev = skb->dev; 118 118
+1 -1
net/xfrm/xfrm_policy.c
··· 2561 2561 default: 2562 2562 BUG(); 2563 2563 } 2564 - xdst = dst_alloc(dst_ops, NULL, 1, DST_OBSOLETE_NONE, 0); 2564 + xdst = dst_alloc(dst_ops, NULL, DST_OBSOLETE_NONE, 0); 2565 2565 2566 2566 if (likely(xdst)) { 2567 2567 memset_after(xdst, 0, u.dst);