Lines Matching refs:rt
551 static unsigned int mctp_route_mtu(struct mctp_route *rt) in mctp_route_mtu() argument
553 return rt->mtu ?: READ_ONCE(rt->dev->dev->mtu); in mctp_route_mtu()
604 static void mctp_route_release(struct mctp_route *rt) in mctp_route_release() argument
606 if (refcount_dec_and_test(&rt->refs)) { in mctp_route_release()
607 mctp_dev_put(rt->dev); in mctp_route_release()
608 kfree_rcu(rt, rcu); in mctp_route_release()
615 struct mctp_route *rt; in mctp_route_alloc() local
617 rt = kzalloc(sizeof(*rt), GFP_KERNEL); in mctp_route_alloc()
618 if (!rt) in mctp_route_alloc()
621 INIT_LIST_HEAD(&rt->list); in mctp_route_alloc()
622 refcount_set(&rt->refs, 1); in mctp_route_alloc()
623 rt->output = mctp_route_discard; in mctp_route_alloc()
625 return rt; in mctp_route_alloc()
796 static bool mctp_rt_match_eid(struct mctp_route *rt, in mctp_rt_match_eid() argument
799 return READ_ONCE(rt->dev->net) == net && in mctp_rt_match_eid()
800 rt->min <= eid && rt->max >= eid; in mctp_rt_match_eid()
816 struct mctp_route *tmp, *rt = NULL; in mctp_route_lookup() local
824 rt = tmp; in mctp_route_lookup()
832 return rt; in mctp_route_lookup()
838 struct mctp_route *tmp, *rt = NULL; in mctp_route_lookup_null() local
845 rt = tmp; in mctp_route_lookup_null()
852 return rt; in mctp_route_lookup_null()
855 static int mctp_do_fragment_route(struct mctp_route *rt, struct sk_buff *skb, in mctp_do_fragment_route() argument
928 rc = rt->output(rt, skb2); in mctp_do_fragment_route()
940 int mctp_local_output(struct sock *sk, struct mctp_route *rt, in mctp_local_output() argument
958 if (rt) { in mctp_local_output()
960 if (WARN_ON(!rt->dev)) in mctp_local_output()
967 rt = &tmp_rt; in mctp_local_output()
975 rt->dev = __mctp_dev_get(dev); in mctp_local_output()
978 if (!rt->dev) in mctp_local_output()
984 rt->output = mctp_route_output; in mctp_local_output()
985 rt->mtu = 0; in mctp_local_output()
992 spin_lock_irqsave(&rt->dev->addrs_lock, flags); in mctp_local_output()
993 if (rt->dev->num_addrs == 0) { in mctp_local_output()
997 saddr = rt->dev->addrs[0]; in mctp_local_output()
1000 spin_unlock_irqrestore(&rt->dev->addrs_lock, flags); in mctp_local_output()
1001 netid = READ_ONCE(rt->dev->net); in mctp_local_output()
1032 skb->dev = rt->dev->dev; in mctp_local_output()
1043 mtu = mctp_route_mtu(rt); in mctp_local_output()
1048 rc = rt->output(rt, skb); in mctp_local_output()
1050 rc = mctp_do_fragment_route(rt, skb, mtu, tag); in mctp_local_output()
1058 mctp_route_release(rt); in mctp_local_output()
1072 int (*rtfn)(struct mctp_route *rt, struct sk_buff *skb); in mctp_route_add()
1074 struct mctp_route *rt, *ert; in mctp_route_add() local
1093 rt = mctp_route_alloc(); in mctp_route_add()
1094 if (!rt) in mctp_route_add()
1097 rt->min = daddr_start; in mctp_route_add()
1098 rt->max = daddr_start + daddr_extent; in mctp_route_add()
1099 rt->mtu = mtu; in mctp_route_add()
1100 rt->dev = mdev; in mctp_route_add()
1101 mctp_dev_hold(rt->dev); in mctp_route_add()
1102 rt->type = type; in mctp_route_add()
1103 rt->output = rtfn; in mctp_route_add()
1108 if (mctp_rt_compare_exact(rt, ert)) { in mctp_route_add()
1109 mctp_route_release(rt); in mctp_route_add()
1114 list_add_rcu(&rt->list, &net->mctp.routes); in mctp_route_add()
1123 struct mctp_route *rt, *tmp; in mctp_route_remove() local
1135 list_for_each_entry_safe(rt, tmp, &net->mctp.routes, list) { in mctp_route_remove()
1136 if (rt->dev == mdev && in mctp_route_remove()
1137 rt->min == daddr_start && rt->max == daddr_end && in mctp_route_remove()
1138 rt->type == type) { in mctp_route_remove()
1139 list_del_rcu(&rt->list); in mctp_route_remove()
1141 mctp_route_release(rt); in mctp_route_remove()
1163 struct mctp_route *rt, *tmp; in mctp_route_remove_dev() local
1166 list_for_each_entry_safe(rt, tmp, &net->mctp.routes, list) { in mctp_route_remove_dev()
1167 if (rt->dev == mdev) { in mctp_route_remove_dev()
1168 list_del_rcu(&rt->list); in mctp_route_remove_dev()
1170 mctp_route_release(rt); in mctp_route_remove_dev()
1184 struct mctp_route *rt; in mctp_pkttype_receive() local
1227 rt = mctp_route_lookup(net, cb->net, mh->dest); in mctp_pkttype_receive()
1230 if (!rt && mh->dest == MCTP_ADDR_NULL && skb->pkt_type == PACKET_HOST) in mctp_pkttype_receive()
1231 rt = mctp_route_lookup_null(net, dev); in mctp_pkttype_receive()
1233 if (!rt) in mctp_pkttype_receive()
1236 rt->output(rt, skb); in mctp_pkttype_receive()
1237 mctp_route_release(rt); in mctp_pkttype_receive()
1378 static int mctp_fill_rtinfo(struct sk_buff *skb, struct mctp_route *rt, in mctp_fill_rtinfo() argument
1395 hdr->rtm_dst_len = rt->max - rt->min; in mctp_fill_rtinfo()
1401 hdr->rtm_type = rt->type; in mctp_fill_rtinfo()
1403 if (nla_put_u8(skb, RTA_DST, rt->min)) in mctp_fill_rtinfo()
1410 if (rt->mtu) { in mctp_fill_rtinfo()
1411 if (nla_put_u32(skb, RTAX_MTU, rt->mtu)) in mctp_fill_rtinfo()
1417 if (rt->dev) { in mctp_fill_rtinfo()
1418 if (nla_put_u32(skb, RTA_OIF, rt->dev->dev->ifindex)) in mctp_fill_rtinfo()
1436 struct mctp_route *rt; in mctp_dump_rtinfo() local
1448 list_for_each_entry_rcu(rt, &net->mctp.routes, list) { in mctp_dump_rtinfo()
1451 if (mctp_fill_rtinfo(skb, rt, in mctp_dump_rtinfo()
1480 struct mctp_route *rt; in mctp_routes_net_exit() local
1483 list_for_each_entry_rcu(rt, &net->mctp.routes, list) in mctp_routes_net_exit()
1484 mctp_route_release(rt); in mctp_routes_net_exit()