Lines Matching refs:rt

490 static unsigned int mctp_route_mtu(struct mctp_route *rt)  in mctp_route_mtu()  argument
492 return rt->mtu ?: READ_ONCE(rt->dev->dev->mtu); in mctp_route_mtu()
543 static void mctp_route_release(struct mctp_route *rt) in mctp_route_release() argument
545 if (refcount_dec_and_test(&rt->refs)) { in mctp_route_release()
546 mctp_dev_put(rt->dev); in mctp_route_release()
547 kfree_rcu(rt, rcu); in mctp_route_release()
554 struct mctp_route *rt; in mctp_route_alloc() local
556 rt = kzalloc(sizeof(*rt), GFP_KERNEL); in mctp_route_alloc()
557 if (!rt) in mctp_route_alloc()
560 INIT_LIST_HEAD(&rt->list); in mctp_route_alloc()
561 refcount_set(&rt->refs, 1); in mctp_route_alloc()
562 rt->output = mctp_route_discard; in mctp_route_alloc()
564 return rt; in mctp_route_alloc()
718 static bool mctp_rt_match_eid(struct mctp_route *rt, in mctp_rt_match_eid() argument
721 return READ_ONCE(rt->dev->net) == net && in mctp_rt_match_eid()
722 rt->min <= eid && rt->max >= eid; in mctp_rt_match_eid()
738 struct mctp_route *tmp, *rt = NULL; in mctp_route_lookup() local
746 rt = tmp; in mctp_route_lookup()
754 return rt; in mctp_route_lookup()
760 struct mctp_route *tmp, *rt = NULL; in mctp_route_lookup_null() local
767 rt = tmp; in mctp_route_lookup_null()
774 return rt; in mctp_route_lookup_null()
777 static int mctp_do_fragment_route(struct mctp_route *rt, struct sk_buff *skb, in mctp_do_fragment_route() argument
847 rc = rt->output(rt, skb2); in mctp_do_fragment_route()
859 int mctp_local_output(struct sock *sk, struct mctp_route *rt, in mctp_local_output() argument
876 if (rt) { in mctp_local_output()
878 if (WARN_ON(!rt->dev)) in mctp_local_output()
885 rt = &tmp_rt; in mctp_local_output()
893 rt->dev = __mctp_dev_get(dev); in mctp_local_output()
896 if (!rt->dev) in mctp_local_output()
902 rt->output = mctp_route_output; in mctp_local_output()
903 rt->mtu = 0; in mctp_local_output()
910 spin_lock_irqsave(&rt->dev->addrs_lock, flags); in mctp_local_output()
911 if (rt->dev->num_addrs == 0) { in mctp_local_output()
915 saddr = rt->dev->addrs[0]; in mctp_local_output()
918 spin_unlock_irqrestore(&rt->dev->addrs_lock, flags); in mctp_local_output()
949 skb->dev = rt->dev->dev; in mctp_local_output()
960 mtu = mctp_route_mtu(rt); in mctp_local_output()
965 rc = rt->output(rt, skb); in mctp_local_output()
967 rc = mctp_do_fragment_route(rt, skb, mtu, tag); in mctp_local_output()
975 mctp_route_release(rt); in mctp_local_output()
989 int (*rtfn)(struct mctp_route *rt, struct sk_buff *skb); in mctp_route_add()
991 struct mctp_route *rt, *ert; in mctp_route_add() local
1010 rt = mctp_route_alloc(); in mctp_route_add()
1011 if (!rt) in mctp_route_add()
1014 rt->min = daddr_start; in mctp_route_add()
1015 rt->max = daddr_start + daddr_extent; in mctp_route_add()
1016 rt->mtu = mtu; in mctp_route_add()
1017 rt->dev = mdev; in mctp_route_add()
1018 mctp_dev_hold(rt->dev); in mctp_route_add()
1019 rt->type = type; in mctp_route_add()
1020 rt->output = rtfn; in mctp_route_add()
1025 if (mctp_rt_compare_exact(rt, ert)) { in mctp_route_add()
1026 mctp_route_release(rt); in mctp_route_add()
1031 list_add_rcu(&rt->list, &net->mctp.routes); in mctp_route_add()
1040 struct mctp_route *rt, *tmp; in mctp_route_remove() local
1052 list_for_each_entry_safe(rt, tmp, &net->mctp.routes, list) { in mctp_route_remove()
1053 if (rt->dev == mdev && in mctp_route_remove()
1054 rt->min == daddr_start && rt->max == daddr_end && in mctp_route_remove()
1055 rt->type == type) { in mctp_route_remove()
1056 list_del_rcu(&rt->list); in mctp_route_remove()
1058 mctp_route_release(rt); in mctp_route_remove()
1080 struct mctp_route *rt, *tmp; in mctp_route_remove_dev() local
1083 list_for_each_entry_safe(rt, tmp, &net->mctp.routes, list) { in mctp_route_remove_dev()
1084 if (rt->dev == mdev) { in mctp_route_remove_dev()
1085 list_del_rcu(&rt->list); in mctp_route_remove_dev()
1087 mctp_route_release(rt); in mctp_route_remove_dev()
1101 struct mctp_route *rt; in mctp_pkttype_receive() local
1144 rt = mctp_route_lookup(net, cb->net, mh->dest); in mctp_pkttype_receive()
1147 if (!rt && mh->dest == MCTP_ADDR_NULL && skb->pkt_type == PACKET_HOST) in mctp_pkttype_receive()
1148 rt = mctp_route_lookup_null(net, dev); in mctp_pkttype_receive()
1150 if (!rt) in mctp_pkttype_receive()
1153 rt->output(rt, skb); in mctp_pkttype_receive()
1154 mctp_route_release(rt); in mctp_pkttype_receive()
1295 static int mctp_fill_rtinfo(struct sk_buff *skb, struct mctp_route *rt, in mctp_fill_rtinfo() argument
1312 hdr->rtm_dst_len = rt->max - rt->min; in mctp_fill_rtinfo()
1318 hdr->rtm_type = rt->type; in mctp_fill_rtinfo()
1320 if (nla_put_u8(skb, RTA_DST, rt->min)) in mctp_fill_rtinfo()
1327 if (rt->mtu) { in mctp_fill_rtinfo()
1328 if (nla_put_u32(skb, RTAX_MTU, rt->mtu)) in mctp_fill_rtinfo()
1334 if (rt->dev) { in mctp_fill_rtinfo()
1335 if (nla_put_u32(skb, RTA_OIF, rt->dev->dev->ifindex)) in mctp_fill_rtinfo()
1353 struct mctp_route *rt; in mctp_dump_rtinfo() local
1365 list_for_each_entry_rcu(rt, &net->mctp.routes, list) { in mctp_dump_rtinfo()
1368 if (mctp_fill_rtinfo(skb, rt, in mctp_dump_rtinfo()
1397 struct mctp_route *rt; in mctp_routes_net_exit() local
1400 list_for_each_entry_rcu(rt, &net->mctp.routes, list) in mctp_routes_net_exit()
1401 mctp_route_release(rt); in mctp_routes_net_exit()