Lines Matching +full:use +full:- +full:rtm
1 // SPDX-License-Identifier: GPL-2.0
3 * Management Component Transport Protocol (MCTP) - routing
50 /* TODO: look up in skb->cb? */ in mctp_lookup_bind()
56 type = (*(u8 *)skb->data) & 0x7f; in mctp_lookup_bind()
58 sk_for_each_rcu(sk, &net->mctp.binds) { in mctp_lookup_bind()
61 if (msk->bind_net != MCTP_NET_ANY && msk->bind_net != cb->net) in mctp_lookup_bind()
64 if (msk->bind_type != type) in mctp_lookup_bind()
67 if (!mctp_address_matches(msk->bind_addr, mh->dest)) in mctp_lookup_bind()
78 * struct net->mctp.keys contains our set of currently-allocated keys for
85 * a key with (local = local-eid, peer = ANY). This allows a match on the
91 * - when a packet is sent, with a locally-owned tag: we need to find an
94 * - when a tag is manually allocated: we need to find an unused tag value
98 * (local = ANY, peer = peer-eid).
113 if (key->net != net) in mctp_key_match()
116 if (!mctp_address_matches(key->local_addr, local)) in mctp_key_match()
119 if (!mctp_address_matches(key->peer_addr, peer)) in mctp_key_match()
122 if (key->tag != tag) in mctp_key_match()
128 /* returns a key (with key->lock held, and refcounted), or NULL if no such
134 __acquires(&key->lock) in mctp_lookup_key()
142 tag = mh->flags_seq_tag & (MCTP_HDR_TAG_MASK | MCTP_HDR_FLAG_TO); in mctp_lookup_key()
145 spin_lock_irqsave(&net->mctp.keys_lock, flags); in mctp_lookup_key()
147 hlist_for_each_entry(key, &net->mctp.keys, hlist) { in mctp_lookup_key()
148 if (!mctp_key_match(key, netid, mh->dest, peer, tag)) in mctp_lookup_key()
151 spin_lock(&key->lock); in mctp_lookup_key()
152 if (key->valid) { in mctp_lookup_key()
153 refcount_inc(&key->refs); in mctp_lookup_key()
157 spin_unlock(&key->lock); in mctp_lookup_key()
161 spin_unlock(&net->mctp.keys_lock); in mctp_lookup_key()
164 spin_unlock_irqrestore(&net->mctp.keys_lock, flags); in mctp_lookup_key()
181 key->net = net; in mctp_key_alloc()
182 key->peer_addr = peer; in mctp_key_alloc()
183 key->local_addr = local; in mctp_key_alloc()
184 key->tag = tag; in mctp_key_alloc()
185 key->sk = &msk->sk; in mctp_key_alloc()
186 key->valid = true; in mctp_key_alloc()
187 spin_lock_init(&key->lock); in mctp_key_alloc()
188 refcount_set(&key->refs, 1); in mctp_key_alloc()
189 sock_hold(key->sk); in mctp_key_alloc()
198 if (!refcount_dec_and_test(&key->refs)) in mctp_key_unref()
204 spin_lock_irqsave(&key->lock, flags); in mctp_key_unref()
205 mctp_dev_release_key(key->dev, key); in mctp_key_unref()
206 spin_unlock_irqrestore(&key->lock, flags); in mctp_key_unref()
208 sock_put(key->sk); in mctp_key_unref()
214 struct net *net = sock_net(&msk->sk); in mctp_key_add()
219 spin_lock_irqsave(&net->mctp.keys_lock, flags); in mctp_key_add()
221 if (sock_flag(&msk->sk, SOCK_DEAD)) { in mctp_key_add()
222 rc = -EINVAL; in mctp_key_add()
226 hlist_for_each_entry(tmp, &net->mctp.keys, hlist) { in mctp_key_add()
227 if (mctp_key_match(tmp, key->net, key->local_addr, in mctp_key_add()
228 key->peer_addr, key->tag)) { in mctp_key_add()
229 spin_lock(&tmp->lock); in mctp_key_add()
230 if (tmp->valid) in mctp_key_add()
231 rc = -EEXIST; in mctp_key_add()
232 spin_unlock(&tmp->lock); in mctp_key_add()
239 refcount_inc(&key->refs); in mctp_key_add()
240 key->expiry = jiffies + mctp_key_lifetime; in mctp_key_add()
241 timer_reduce(&msk->key_expiry, key->expiry); in mctp_key_add()
243 hlist_add_head(&key->hlist, &net->mctp.keys); in mctp_key_add()
244 hlist_add_head(&key->sklist, &msk->keys); in mctp_key_add()
248 spin_unlock_irqrestore(&net->mctp.keys_lock, flags); in mctp_key_add()
261 __releases(&key->lock) in __mctp_key_done_in()
266 skb = key->reasm_head; in __mctp_key_done_in()
267 key->reasm_head = NULL; in __mctp_key_done_in()
269 if (!key->manual_alloc) { in __mctp_key_done_in()
270 key->reasm_dead = true; in __mctp_key_done_in()
271 key->valid = false; in __mctp_key_done_in()
272 mctp_dev_release_key(key->dev, key); in __mctp_key_done_in()
274 spin_unlock_irqrestore(&key->lock, flags); in __mctp_key_done_in()
276 if (!key->manual_alloc) { in __mctp_key_done_in()
277 spin_lock_irqsave(&net->mctp.keys_lock, flags); in __mctp_key_done_in()
278 if (!hlist_unhashed(&key->hlist)) { in __mctp_key_done_in()
279 hlist_del_init(&key->hlist); in __mctp_key_done_in()
280 hlist_del_init(&key->sklist); in __mctp_key_done_in()
283 spin_unlock_irqrestore(&net->mctp.keys_lock, flags); in __mctp_key_done_in()
301 refcount_inc(&key->refs); in mctp_skb_set_flow()
302 flow->key = key; in mctp_skb_set_flow()
314 key = flow->key; in mctp_flow_prepare_output()
316 if (WARN_ON(key->dev && key->dev != dev)) in mctp_flow_prepare_output()
331 this_seq = (hdr->flags_seq_tag >> MCTP_HDR_SEQ_SHIFT) in mctp_frag_queue()
334 if (!key->reasm_head) { in mctp_frag_queue()
335 key->reasm_head = skb; in mctp_frag_queue()
336 key->reasm_tailp = &(skb_shinfo(skb)->frag_list); in mctp_frag_queue()
337 key->last_seq = this_seq; in mctp_frag_queue()
341 exp_seq = (key->last_seq + 1) & MCTP_HDR_SEQ_MASK; in mctp_frag_queue()
344 return -EINVAL; in mctp_frag_queue()
346 if (key->reasm_head->len + skb->len > mctp_message_maxlen) in mctp_frag_queue()
347 return -EINVAL; in mctp_frag_queue()
349 skb->next = NULL; in mctp_frag_queue()
350 skb->sk = NULL; in mctp_frag_queue()
351 *key->reasm_tailp = skb; in mctp_frag_queue()
352 key->reasm_tailp = &skb->next; in mctp_frag_queue()
354 key->last_seq = this_seq; in mctp_frag_queue()
356 key->reasm_head->data_len += skb->len; in mctp_frag_queue()
357 key->reasm_head->len += skb->len; in mctp_frag_queue()
358 key->reasm_head->truesize += skb->truesize; in mctp_frag_queue()
366 struct net *net = dev_net(skb->dev); in mctp_route_input()
375 rc = -EINVAL; in mctp_route_input()
377 /* we may be receiving a locally-routed packet; drop source sk in mctp_route_input()
383 if (skb->len < sizeof(struct mctp_hdr) + 1) in mctp_route_input()
388 netid = mctp_cb(skb)->net; in mctp_route_input()
391 if (mh->ver != 1) in mctp_route_input()
394 flags = mh->flags_seq_tag & (MCTP_HDR_FLAG_SOM | MCTP_HDR_FLAG_EOM); in mctp_route_input()
395 tag = mh->flags_seq_tag & (MCTP_HDR_TAG_MASK | MCTP_HDR_FLAG_TO); in mctp_route_input()
400 * we hold a ref on the key, and key->lock held. in mctp_route_input()
402 key = mctp_lookup_key(net, skb, netid, mh->src, &f); in mctp_route_input()
406 msk = container_of(key->sk, struct mctp_sock, sk); in mctp_route_input()
409 * key lookup to find the socket, but don't use this in mctp_route_input()
410 * key for reassembly - we'll create a more specific in mctp_route_input()
413 * this lookup requires key->peer to be MCTP_ADDR_ANY, in mctp_route_input()
414 * it doesn't match just any key->peer. in mctp_route_input()
419 msk = container_of(any_key->sk, in mctp_route_input()
421 spin_unlock_irqrestore(&any_key->lock, f); in mctp_route_input()
429 rc = -ENOENT; in mctp_route_input()
433 /* single-packet message? deliver to socket, clean up any in mctp_route_input()
437 sock_queue_rcv_skb(&msk->sk, skb); in mctp_route_input()
450 /* broadcast response or a bind() - create a key for further in mctp_route_input()
454 key = mctp_key_alloc(msk, netid, mh->dest, mh->src, in mctp_route_input()
457 rc = -ENOMEM; in mctp_route_input()
476 /* we don't need to release key->lock on exit, so in mctp_route_input()
484 if (key->reasm_head || key->reasm_dead) { in mctp_route_input()
488 rc = -EEXIST; in mctp_route_input()
497 * using the message-specific key in mctp_route_input()
501 if (!key->reasm_head) in mctp_route_input()
502 rc = -EINVAL; in mctp_route_input()
510 sock_queue_rcv_skb(key->sk, key->reasm_head); in mctp_route_input()
511 key->reasm_head = NULL; in mctp_route_input()
518 rc = -ENOENT; in mctp_route_input()
524 spin_unlock_irqrestore(&key->lock, f); in mctp_route_input()
537 return rt->mtu ?: READ_ONCE(rt->dev->dev->mtu); in mctp_route_mtu()
549 skb->protocol = htons(ETH_P_MCTP); in mctp_route_output()
551 mtu = READ_ONCE(skb->dev->mtu); in mctp_route_output()
552 if (skb->len > mtu) { in mctp_route_output()
554 return -EMSGSIZE; in mctp_route_output()
557 if (cb->ifindex) { in mctp_route_output()
558 /* direct route; use the hwaddr we stashed in sendmsg */ in mctp_route_output()
559 if (cb->halen != skb->dev->addr_len) { in mctp_route_output()
562 return -EMSGSIZE; in mctp_route_output()
564 daddr = cb->haddr; in mctp_route_output()
567 if (mctp_neigh_lookup(route->dev, hdr->dest, daddr_buf) == 0) in mctp_route_output()
571 rc = dev_hard_header(skb, skb->dev, ntohs(skb->protocol), in mctp_route_output()
572 daddr, skb->dev->dev_addr, skb->len); in mctp_route_output()
575 return -EHOSTUNREACH; in mctp_route_output()
578 mctp_flow_prepare_output(skb, route->dev); in mctp_route_output()
590 if (refcount_dec_and_test(&rt->refs)) { in mctp_route_release()
591 mctp_dev_put(rt->dev); in mctp_route_release()
605 INIT_LIST_HEAD(&rt->list); in mctp_route_alloc()
606 refcount_set(&rt->refs, 1); in mctp_route_alloc()
607 rt->output = mctp_route_discard; in mctp_route_alloc()
614 return READ_ONCE(net->mctp.default_net); in mctp_default_net()
620 return -EINVAL; in mctp_default_net_set()
621 WRITE_ONCE(net->mctp.default_net, index); in mctp_default_net_set()
629 struct netns_mctp *mns = &net->mctp; in mctp_reserve_tag()
631 lockdep_assert_held(&mns->keys_lock); in mctp_reserve_tag()
633 key->expiry = jiffies + mctp_key_lifetime; in mctp_reserve_tag()
634 timer_reduce(&msk->key_expiry, key->expiry); in mctp_reserve_tag()
636 /* we hold the net->key_lock here, allowing updates to both in mctp_reserve_tag()
639 hlist_add_head_rcu(&key->hlist, &mns->keys); in mctp_reserve_tag()
640 hlist_add_head_rcu(&key->sklist, &msk->keys); in mctp_reserve_tag()
641 refcount_inc(&key->refs); in mctp_reserve_tag()
644 /* Allocate a locally-owned tag value for (local, peer), and reserve
652 struct net *net = sock_net(&msk->sk); in mctp_alloc_local_tag()
653 struct netns_mctp *mns = &net->mctp; in mctp_alloc_local_tag()
665 return ERR_PTR(-ENOMEM); in mctp_alloc_local_tag()
670 spin_lock_irqsave(&mns->keys_lock, flags); in mctp_alloc_local_tag()
675 hlist_for_each_entry(tmp, &mns->keys, hlist) { in mctp_alloc_local_tag()
680 /* tags are net-specific */ in mctp_alloc_local_tag()
681 if (tmp->net != netid) in mctp_alloc_local_tag()
685 if (tmp->tag & MCTP_HDR_FLAG_TO) in mctp_alloc_local_tag()
693 !mctp_address_matches(tmp->peer_addr, peer)) in mctp_alloc_local_tag()
697 !mctp_address_matches(tmp->local_addr, local)) in mctp_alloc_local_tag()
700 spin_lock(&tmp->lock); in mctp_alloc_local_tag()
704 if (tmp->valid) in mctp_alloc_local_tag()
705 tagbits &= ~(1 << tmp->tag); in mctp_alloc_local_tag()
706 spin_unlock(&tmp->lock); in mctp_alloc_local_tag()
713 key->tag = __ffs(tagbits); in mctp_alloc_local_tag()
717 key->manual_alloc = manual; in mctp_alloc_local_tag()
718 *tagp = key->tag; in mctp_alloc_local_tag()
721 spin_unlock_irqrestore(&mns->keys_lock, flags); in mctp_alloc_local_tag()
725 return ERR_PTR(-EBUSY); in mctp_alloc_local_tag()
736 struct net *net = sock_net(&msk->sk); in mctp_lookup_prealloc_tag()
737 struct netns_mctp *mns = &net->mctp; in mctp_lookup_prealloc_tag()
744 spin_lock_irqsave(&mns->keys_lock, flags); in mctp_lookup_prealloc_tag()
746 hlist_for_each_entry(tmp, &mns->keys, hlist) { in mctp_lookup_prealloc_tag()
747 if (tmp->net != netid) in mctp_lookup_prealloc_tag()
750 if (tmp->tag != req_tag) in mctp_lookup_prealloc_tag()
753 if (!mctp_address_matches(tmp->peer_addr, daddr)) in mctp_lookup_prealloc_tag()
756 if (!tmp->manual_alloc) in mctp_lookup_prealloc_tag()
759 spin_lock(&tmp->lock); in mctp_lookup_prealloc_tag()
760 if (tmp->valid) { in mctp_lookup_prealloc_tag()
762 refcount_inc(&key->refs); in mctp_lookup_prealloc_tag()
763 spin_unlock(&tmp->lock); in mctp_lookup_prealloc_tag()
766 spin_unlock(&tmp->lock); in mctp_lookup_prealloc_tag()
768 spin_unlock_irqrestore(&mns->keys_lock, flags); in mctp_lookup_prealloc_tag()
771 return ERR_PTR(-ENOENT); in mctp_lookup_prealloc_tag()
774 *tagp = key->tag; in mctp_lookup_prealloc_tag()
783 return READ_ONCE(rt->dev->net) == net && in mctp_rt_match_eid()
784 rt->min <= eid && rt->max >= eid; in mctp_rt_match_eid()
792 return rt1->dev->net == rt2->dev->net && in mctp_rt_compare_exact()
793 rt1->min == rt2->min && in mctp_rt_compare_exact()
794 rt1->max == rt2->max; in mctp_rt_compare_exact()
804 list_for_each_entry_rcu(tmp, &net->mctp.routes, list) { in mctp_route_lookup()
807 if (refcount_inc_not_zero(&tmp->refs)) { in mctp_route_lookup()
826 list_for_each_entry_rcu(tmp, &net->mctp.routes, list) { in mctp_route_lookup_null()
827 if (tmp->dev->dev == dev && tmp->type == RTN_LOCAL && in mctp_route_lookup_null()
828 refcount_inc_not_zero(&tmp->refs)) { in mctp_route_lookup_null()
855 return -EMSGSIZE; in mctp_do_fragment_route()
864 for (pos = 0; pos < skb->len;) { in mctp_do_fragment_route()
866 size = min(mtu - hlen, skb->len - pos); in mctp_do_fragment_route()
870 rc = -ENOMEM; in mctp_do_fragment_route()
875 skb2->protocol = skb->protocol; in mctp_do_fragment_route()
876 skb2->priority = skb->priority; in mctp_do_fragment_route()
877 skb2->dev = skb->dev; in mctp_do_fragment_route()
878 memcpy(skb2->cb, skb->cb, sizeof(skb2->cb)); in mctp_do_fragment_route()
880 if (skb->sk) in mctp_do_fragment_route()
881 skb_set_owner_w(skb2, skb->sk); in mctp_do_fragment_route()
887 skb2->transport_header = skb2->network_header + hlen; in mctp_do_fragment_route()
891 hdr2->ver = hdr->ver; in mctp_do_fragment_route()
892 hdr2->dest = hdr->dest; in mctp_do_fragment_route()
893 hdr2->src = hdr->src; in mctp_do_fragment_route()
894 hdr2->flags_seq_tag = tag & in mctp_do_fragment_route()
898 hdr2->flags_seq_tag |= MCTP_HDR_FLAG_SOM; in mctp_do_fragment_route()
900 if (pos + size == skb->len) in mctp_do_fragment_route()
901 hdr2->flags_seq_tag |= MCTP_HDR_FLAG_EOM; in mctp_do_fragment_route()
903 hdr2->flags_seq_tag |= seq << MCTP_HDR_SEQ_SHIFT; in mctp_do_fragment_route()
912 rc = rt->output(rt, skb2); in mctp_do_fragment_route()
940 rc = -ENODEV; in mctp_local_output()
944 if (WARN_ON(!rt->dev)) in mctp_local_output()
947 } else if (cb->ifindex) { in mctp_local_output()
954 dev = dev_get_by_index_rcu(sock_net(sk), cb->ifindex); in mctp_local_output()
959 rt->dev = __mctp_dev_get(dev); in mctp_local_output()
962 if (!rt->dev) in mctp_local_output()
965 /* establish temporary route - we set up enough to keep in mctp_local_output()
968 rt->output = mctp_route_output; in mctp_local_output()
969 rt->mtu = 0; in mctp_local_output()
972 rc = -EINVAL; in mctp_local_output()
976 spin_lock_irqsave(&rt->dev->addrs_lock, flags); in mctp_local_output()
977 if (rt->dev->num_addrs == 0) { in mctp_local_output()
978 rc = -EHOSTUNREACH; in mctp_local_output()
980 /* use the outbound interface's first address as our source */ in mctp_local_output()
981 saddr = rt->dev->addrs[0]; in mctp_local_output()
984 spin_unlock_irqrestore(&rt->dev->addrs_lock, flags); in mctp_local_output()
985 netid = READ_ONCE(rt->dev->net); in mctp_local_output()
1011 skb->protocol = htons(ETH_P_MCTP); in mctp_local_output()
1012 skb->priority = 0; in mctp_local_output()
1016 skb->dev = rt->dev->dev; in mctp_local_output()
1018 /* cb->net will have been set on initial ingress */ in mctp_local_output()
1019 cb->src = saddr; in mctp_local_output()
1023 hdr->ver = 1; in mctp_local_output()
1024 hdr->dest = daddr; in mctp_local_output()
1025 hdr->src = saddr; in mctp_local_output()
1029 if (skb->len + sizeof(struct mctp_hdr) <= mtu) { in mctp_local_output()
1030 hdr->flags_seq_tag = MCTP_HDR_FLAG_SOM | in mctp_local_output()
1032 rc = rt->output(rt, skb); in mctp_local_output()
1057 struct net *net = dev_net(mdev->dev); in mctp_route_add()
1061 return -EINVAL; in mctp_route_add()
1064 return -EINVAL; in mctp_route_add()
1074 return -EINVAL; in mctp_route_add()
1079 return -ENOMEM; in mctp_route_add()
1081 rt->min = daddr_start; in mctp_route_add()
1082 rt->max = daddr_start + daddr_extent; in mctp_route_add()
1083 rt->mtu = mtu; in mctp_route_add()
1084 rt->dev = mdev; in mctp_route_add()
1085 mctp_dev_hold(rt->dev); in mctp_route_add()
1086 rt->type = type; in mctp_route_add()
1087 rt->output = rtfn; in mctp_route_add()
1091 list_for_each_entry(ert, &net->mctp.routes, list) { in mctp_route_add()
1094 return -EEXIST; in mctp_route_add()
1098 list_add_rcu(&rt->list, &net->mctp.routes); in mctp_route_add()
1106 struct net *net = dev_net(mdev->dev); in mctp_route_remove()
1112 return -EINVAL; in mctp_route_remove()
1119 list_for_each_entry_safe(rt, tmp, &net->mctp.routes, list) { in mctp_route_remove()
1120 if (rt->dev == mdev && in mctp_route_remove()
1121 rt->min == daddr_start && rt->max == daddr_end && in mctp_route_remove()
1122 rt->type == type) { in mctp_route_remove()
1123 list_del_rcu(&rt->list); in mctp_route_remove()
1130 return dropped ? 0 : -ENOENT; in mctp_route_remove()
1146 struct net *net = dev_net(mdev->dev); in mctp_route_remove_dev()
1150 list_for_each_entry_safe(rt, tmp, &net->mctp.routes, list) { in mctp_route_remove_dev()
1151 if (rt->dev == mdev) { in mctp_route_remove_dev()
1152 list_del_rcu(&rt->list); in mctp_route_remove_dev()
1159 /* Incoming packet-handling */
1175 /* basic non-data sanity checks */ in mctp_pkttype_receive()
1187 if (mh->ver < MCTP_VER_MIN || mh->ver > MCTP_VER_MAX) in mctp_pkttype_receive()
1193 if (!(mctp_address_unicast(mh->src) || mctp_address_null(mh->src))) in mctp_pkttype_receive()
1197 if (!(mctp_address_unicast(mh->dest) || mctp_address_null(mh->dest) || in mctp_pkttype_receive()
1198 mctp_address_broadcast(mh->dest))) in mctp_pkttype_receive()
1202 if (dev->type == ARPHRD_MCTP) { in mctp_pkttype_receive()
1206 cb->halen = 0; in mctp_pkttype_receive()
1208 cb->net = READ_ONCE(mdev->net); in mctp_pkttype_receive()
1209 cb->ifindex = dev->ifindex; in mctp_pkttype_receive()
1211 rt = mctp_route_lookup(net, cb->net, mh->dest); in mctp_pkttype_receive()
1214 if (!rt && mh->dest == MCTP_ADDR_NULL && skb->pkt_type == PACKET_HOST) in mctp_pkttype_receive()
1220 rt->output(rt, skb); in mctp_pkttype_receive()
1250 struct nlattr **tb, struct rtmsg **rtm, in mctp_route_nlparse() argument
1253 struct net *net = sock_net(skb->sk); in mctp_route_nlparse()
1267 return -EINVAL; in mctp_route_nlparse()
1273 return -EINVAL; in mctp_route_nlparse()
1277 *rtm = nlmsg_data(nlh); in mctp_route_nlparse()
1278 if ((*rtm)->rtm_family != AF_MCTP) { in mctp_route_nlparse()
1280 return -EINVAL; in mctp_route_nlparse()
1286 return -ENODEV; in mctp_route_nlparse()
1290 return -ENODEV; in mctp_route_nlparse()
1292 if (dev->flags & IFF_LOOPBACK) { in mctp_route_nlparse()
1294 return -EINVAL; in mctp_route_nlparse()
1311 struct rtmsg *rtm; in mctp_newroute() local
1316 &rtm, &mdev, &daddr_start); in mctp_newroute()
1320 if (rtm->rtm_type != RTN_UNICAST) { in mctp_newroute()
1322 return -EINVAL; in mctp_newroute()
1335 rc = mctp_route_add(mdev, daddr_start, rtm->rtm_dst_len, mtu, in mctp_newroute()
1336 rtm->rtm_type); in mctp_newroute()
1346 struct rtmsg *rtm; in mctp_delroute() local
1350 &rtm, &mdev, &daddr_start); in mctp_delroute()
1355 if (rtm->rtm_type != RTN_UNICAST) in mctp_delroute()
1356 return -EINVAL; in mctp_delroute()
1358 rc = mctp_route_remove(mdev, daddr_start, rtm->rtm_dst_len, RTN_UNICAST); in mctp_delroute()
1371 return -EMSGSIZE; in mctp_fill_rtinfo()
1374 hdr->rtm_family = AF_MCTP; in mctp_fill_rtinfo()
1376 /* we use the _len fields as a number of EIDs, rather than in mctp_fill_rtinfo()
1379 hdr->rtm_dst_len = rt->max - rt->min; in mctp_fill_rtinfo()
1380 hdr->rtm_src_len = 0; in mctp_fill_rtinfo()
1381 hdr->rtm_tos = 0; in mctp_fill_rtinfo()
1382 hdr->rtm_table = RT_TABLE_DEFAULT; in mctp_fill_rtinfo()
1383 hdr->rtm_protocol = RTPROT_STATIC; /* everything is user-defined */ in mctp_fill_rtinfo()
1384 hdr->rtm_scope = RT_SCOPE_LINK; /* TODO: scope in mctp_route? */ in mctp_fill_rtinfo()
1385 hdr->rtm_type = rt->type; in mctp_fill_rtinfo()
1387 if (nla_put_u8(skb, RTA_DST, rt->min)) in mctp_fill_rtinfo()
1394 if (rt->mtu) { in mctp_fill_rtinfo()
1395 if (nla_put_u32(skb, RTAX_MTU, rt->mtu)) in mctp_fill_rtinfo()
1401 if (rt->dev) { in mctp_fill_rtinfo()
1402 if (nla_put_u32(skb, RTA_OIF, rt->dev->dev->ifindex)) in mctp_fill_rtinfo()
1414 return -EMSGSIZE; in mctp_fill_rtinfo()
1419 struct net *net = sock_net(skb->sk); in mctp_dump_rtinfo()
1424 * cb->strict_check in mctp_dump_rtinfo()
1428 s_idx = cb->args[0]; in mctp_dump_rtinfo()
1432 list_for_each_entry_rcu(rt, &net->mctp.routes, list) { in mctp_dump_rtinfo()
1436 NETLINK_CB(cb->skb).portid, in mctp_dump_rtinfo()
1437 cb->nlh->nlmsg_seq, in mctp_dump_rtinfo()
1443 cb->args[0] = idx; in mctp_dump_rtinfo()
1445 return skb->len; in mctp_dump_rtinfo()
1451 struct netns_mctp *ns = &net->mctp; in mctp_routes_net_init()
1453 INIT_LIST_HEAD(&ns->routes); in mctp_routes_net_init()
1454 INIT_HLIST_HEAD(&ns->binds); in mctp_routes_net_init()
1455 mutex_init(&ns->bind_lock); in mctp_routes_net_init()
1456 INIT_HLIST_HEAD(&ns->keys); in mctp_routes_net_init()
1457 spin_lock_init(&ns->keys_lock); in mctp_routes_net_init()
1467 list_for_each_entry_rcu(rt, &net->mctp.routes, list) in mctp_routes_net_exit()
1514 #include "test/route-test.c"