Lines Matching +full:echo +full:- +full:active +full:- +full:ms
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * (C) 2012-2014 by sysmocom - s.f.m.c. GmbH
36 /* An active session for the subscriber. */
57 } ms; member
95 } ms; member
139 return jhash_2words((__force u32)ip6->s6_addr32[0], in ipv6_hashfn()
140 (__force u32)ip6->s6_addr32[1], gtp_h_initval); in ipv6_hashfn()
149 head = >p->tid_hash[gtp0_hashfn(tid) % gtp->hash_size]; in gtp0_pdp_find()
152 if (pdp->af == family && in gtp0_pdp_find()
153 pdp->gtp_version == GTP_V0 && in gtp0_pdp_find()
154 pdp->u.v0.tid == tid) in gtp0_pdp_find()
166 head = >p->tid_hash[gtp1u_hashfn(tid) % gtp->hash_size]; in gtp1_pdp_find()
169 if (pdp->af == family && in gtp1_pdp_find()
170 pdp->gtp_version == GTP_V1 && in gtp1_pdp_find()
171 pdp->u.v1.i_tei == tid) in gtp1_pdp_find()
177 /* Resolve a PDP context based on IPv4 address of MS. */
183 head = >p->addr_hash[ipv4_hashfn(ms_addr) % gtp->hash_size]; in ipv4_pdp_find()
186 if (pdp->af == AF_INET && in ipv4_pdp_find()
187 pdp->ms.addr.s_addr == ms_addr) in ipv4_pdp_find()
194 /* 3GPP TS 29.060: PDN Connection: the association between a MS represented by
202 * than those that start with binary 000 have a 64-bit interface ID field
208 return a->s6_addr32[0] == b->s6_addr32[0] && in ipv6_pdp_addr_equal()
209 a->s6_addr32[1] == b->s6_addr32[1]; in ipv6_pdp_addr_equal()
218 head = >p->addr_hash[ipv6_hashfn(ms_addr) % gtp->hash_size]; in ipv6_pdp_find()
221 if (pdp->af == AF_INET6 && in ipv6_pdp_find()
222 ipv6_pdp_addr_equal(&pdp->ms.addr6, ms_addr)) in ipv6_pdp_find()
237 iph = (struct iphdr *)(skb->data + hdrlen); in gtp_check_ms_ipv4()
240 return iph->daddr == pctx->ms.addr.s_addr; in gtp_check_ms_ipv4()
242 return iph->saddr == pctx->ms.addr.s_addr; in gtp_check_ms_ipv4()
254 ip6h = (struct ipv6hdr *)(skb->data + hdrlen); in gtp_check_ms_ipv6()
256 if ((ipv6_addr_type(&ip6h->saddr) & IPV6_ADDR_LINKLOCAL) || in gtp_check_ms_ipv6()
257 (ipv6_addr_type(&ip6h->daddr) & IPV6_ADDR_LINKLOCAL)) in gtp_check_ms_ipv6()
261 ret = ipv6_pdp_addr_equal(&ip6h->daddr, &pctx->ms.addr6); in gtp_check_ms_ipv6()
263 ret = ipv6_pdp_addr_equal(&ip6h->saddr, &pctx->ms.addr6); in gtp_check_ms_ipv6()
293 return -1; in gtp_inner_proto()
303 return -1; in gtp_inner_proto()
313 netdev_dbg(pctx->dev, "No PDP ctx for this MS\n"); in gtp_rx()
319 !net_eq(sock_net(pctx->sk), dev_net(pctx->dev)))) { in gtp_rx()
320 pctx->dev->stats.rx_length_errors++; in gtp_rx()
324 netdev_dbg(pctx->dev, "forwarding packet from GGSN to uplink\n"); in gtp_rx()
333 skb->dev = pctx->dev; in gtp_rx()
335 dev_sw_netstats_rx_add(pctx->dev, skb->len); in gtp_rx()
341 pctx->dev->stats.rx_dropped++; in gtp_rx()
342 return -1; in gtp_rx()
350 fl4->flowi4_oif = sk->sk_bound_dev_if; in ip4_route_output_gtp()
351 fl4->daddr = daddr; in ip4_route_output_gtp()
352 fl4->saddr = saddr; in ip4_route_output_gtp()
353 fl4->flowi4_tos = ip_sock_rt_tos(sk); in ip4_route_output_gtp()
354 fl4->flowi4_scope = ip_sock_rt_scope(sk); in ip4_route_output_gtp()
355 fl4->flowi4_proto = sk->sk_protocol; in ip4_route_output_gtp()
369 fl6->flowi6_oif = sk->sk_bound_dev_if; in ip6_route_output_gtp()
370 fl6->daddr = *daddr; in ip6_route_output_gtp()
371 fl6->saddr = *saddr; in ip6_route_output_gtp()
372 fl6->flowi6_proto = sk->sk_protocol; in ip6_route_output_gtp()
374 dst = ipv6_stub->ipv6_dst_lookup_flow(net, sk, fl6, NULL); in ip6_route_output_gtp()
376 return ERR_PTR(-ENETUNREACH); in ip6_route_output_gtp()
383 * - TID: is not used and shall be set to 0.
384 * - Flow Label is not used and shall be set to 0
386 * - number: this field is not yet used in signalling messages.
389 * Returns true if the echo req was correct, false otherwise.
393 return !(gtp0->tid || (gtp0->flags ^ 0x1e) || in gtp0_validate_echo_hdr()
394 gtp0->number != 0xff || gtp0->flow); in gtp0_validate_echo_hdr()
402 hdr->flags = 0x1e; /* v0, GTP-non-prime. */ in gtp0_build_echo_msg()
403 hdr->type = msg_type; in gtp0_build_echo_msg()
407 hdr->flow = 0; in gtp0_build_echo_msg()
408 hdr->tid = 0; in gtp0_build_echo_msg()
409 hdr->number = 0xff; in gtp0_build_echo_msg()
410 hdr->spare[0] = 0xff; in gtp0_build_echo_msg()
411 hdr->spare[1] = 0xff; in gtp0_build_echo_msg()
412 hdr->spare[2] = 0xff; in gtp0_build_echo_msg()
418 hdr->length = htons(len_pkt - len_hdr); in gtp0_build_echo_msg()
420 hdr->length = 0; in gtp0_build_echo_msg()
432 rt = ip4_route_output_gtp(&fl4, gtp->sk0, iph->saddr, iph->daddr); in gtp0_send_echo_resp_ip()
434 netdev_dbg(gtp->dev, "no route for echo response from %pI4\n", in gtp0_send_echo_resp_ip()
435 &iph->saddr); in gtp0_send_echo_resp_ip()
436 return -1; in gtp0_send_echo_resp_ip()
439 udp_tunnel_xmit_skb(rt, gtp->sk0, skb, in gtp0_send_echo_resp_ip()
441 iph->tos, in gtp0_send_echo_resp_ip()
442 ip4_dst_hoplimit(&rt->dst), in gtp0_send_echo_resp_ip()
445 !net_eq(sock_net(gtp->sk1u), in gtp0_send_echo_resp_ip()
446 dev_net(gtp->dev)), in gtp0_send_echo_resp_ip()
458 gtp0 = (struct gtp0_header *)(skb->data + sizeof(struct udphdr)); in gtp0_send_echo_resp()
461 return -1; in gtp0_send_echo_resp()
463 seq = gtp0->seq; in gtp0_send_echo_resp()
471 gtp0_build_echo_msg(>p_pkt->gtp0_h, GTP_ECHO_RSP); in gtp0_send_echo_resp()
477 gtp_pkt->gtp0_h.seq = seq; in gtp0_send_echo_resp()
479 gtp_pkt->ie.tag = GTPIE_RECOVERY; in gtp0_send_echo_resp()
480 gtp_pkt->ie.val = gtp->restart_count; in gtp0_send_echo_resp()
482 switch (gtp->sk0->sk_family) { in gtp0_send_echo_resp()
485 return -1; in gtp0_send_echo_resp()
488 return -1; in gtp0_send_echo_resp()
495 int flags, u32 type, struct echo_info echo) in gtp_genl_fill_echo() argument
504 if (nla_put_u32(skb, GTPA_VERSION, echo.gtp_version) || in gtp_genl_fill_echo()
505 nla_put_be32(skb, GTPA_PEER_ADDRESS, echo.peer.addr.s_addr) || in gtp_genl_fill_echo()
506 nla_put_be32(skb, GTPA_MS_ADDRESS, echo.ms.addr.s_addr)) in gtp_genl_fill_echo()
514 return -EMSGSIZE; in gtp_genl_fill_echo()
517 static void gtp0_handle_echo_resp_ip(struct sk_buff *skb, struct echo_info *echo) in gtp0_handle_echo_resp_ip() argument
521 echo->ms.addr.s_addr = iph->daddr; in gtp0_handle_echo_resp_ip()
522 echo->peer.addr.s_addr = iph->saddr; in gtp0_handle_echo_resp_ip()
523 echo->gtp_version = GTP_V0; in gtp0_handle_echo_resp_ip()
529 struct echo_info echo; in gtp0_handle_echo_resp() local
533 gtp0 = (struct gtp0_header *)(skb->data + sizeof(struct udphdr)); in gtp0_handle_echo_resp()
536 return -1; in gtp0_handle_echo_resp()
538 switch (gtp->sk0->sk_family) { in gtp0_handle_echo_resp()
540 gtp0_handle_echo_resp_ip(skb, &echo); in gtp0_handle_echo_resp()
543 return -1; in gtp0_handle_echo_resp()
548 return -ENOMEM; in gtp0_handle_echo_resp()
550 ret = gtp_genl_fill_echo(msg, 0, 0, 0, GTP_CMD_ECHOREQ, echo); in gtp0_handle_echo_resp()
556 return genlmsg_multicast_netns(>p_genl_family, dev_net(gtp->dev), in gtp0_handle_echo_resp()
575 /* 1 means pass up to the stack, -1 means drop and 0 means decapsulated. */
585 return -1; in gtp0_udp_encap_recv()
587 gtp0 = (struct gtp0_header *)(skb->data + sizeof(struct udphdr)); in gtp0_udp_encap_recv()
589 if ((gtp0->flags >> 5) != GTP_V0) in gtp0_udp_encap_recv()
594 * handle echo request. in gtp0_udp_encap_recv()
596 if (gtp0->type == GTP_ECHO_REQ && gtp->sk_created) in gtp0_udp_encap_recv()
599 if (gtp0->type == GTP_ECHO_RSP && gtp->sk_created) in gtp0_udp_encap_recv()
602 if (gtp0->type != GTP_TPDU) in gtp0_udp_encap_recv()
606 netdev_dbg(gtp->dev, "GTP packet does not encapsulate an IP packet\n"); in gtp0_udp_encap_recv()
607 return -1; in gtp0_udp_encap_recv()
610 pctx = gtp0_pdp_find(gtp, be64_to_cpu(gtp0->tid), in gtp0_udp_encap_recv()
613 netdev_dbg(gtp->dev, "No PDP ctx to decap skb=%p\n", skb); in gtp0_udp_encap_recv()
617 return gtp_rx(pctx, skb, hdrlen, gtp->role, inner_proto); in gtp0_udp_encap_recv()
626 hdr->flags = 0x32; /* v1, GTP-non-prime. */ in gtp1u_build_echo_msg()
627 hdr->type = msg_type; in gtp1u_build_echo_msg()
628 /* 3GPP TS 29.281 5.1 - TEID has to be set to 0 */ in gtp1u_build_echo_msg()
629 hdr->tid = 0; in gtp1u_build_echo_msg()
640 hdr->length = htons(len_pkt - len_hdr); in gtp1u_build_echo_msg()
646 hdr->length = htons(len_pkt - len_hdr); in gtp1u_build_echo_msg()
658 gtp1u = (struct gtp1_header_long *)(skb->data + sizeof(struct udphdr)); in gtp1u_send_echo_resp()
660 /* 3GPP TS 29.281 5.1 - For the Echo Request, Echo Response, in gtp1u_send_echo_resp()
664 if (!(gtp1u->flags & GTP1_F_SEQ) || gtp1u->tid) in gtp1u_send_echo_resp()
665 return -1; in gtp1u_send_echo_resp()
674 gtp1u_build_echo_msg(>p_pkt->gtp1u_h, GTP_ECHO_RSP); in gtp1u_send_echo_resp()
676 /* 3GPP TS 29.281 7.7.2 - The Restart Counter value in the in gtp1u_send_echo_resp()
682 gtp_pkt->ie.tag = GTPIE_RECOVERY; in gtp1u_send_echo_resp()
683 gtp_pkt->ie.val = 0; in gtp1u_send_echo_resp()
690 rt = ip4_route_output_gtp(&fl4, gtp->sk1u, iph->saddr, iph->daddr); in gtp1u_send_echo_resp()
692 netdev_dbg(gtp->dev, "no route for echo response from %pI4\n", in gtp1u_send_echo_resp()
693 &iph->saddr); in gtp1u_send_echo_resp()
694 return -1; in gtp1u_send_echo_resp()
697 udp_tunnel_xmit_skb(rt, gtp->sk1u, skb, in gtp1u_send_echo_resp()
699 iph->tos, in gtp1u_send_echo_resp()
700 ip4_dst_hoplimit(&rt->dst), in gtp1u_send_echo_resp()
703 !net_eq(sock_net(gtp->sk1u), in gtp1u_send_echo_resp()
704 dev_net(gtp->dev)), in gtp1u_send_echo_resp()
712 struct echo_info echo; in gtp1u_handle_echo_resp() local
717 gtp1u = (struct gtp1_header_long *)(skb->data + sizeof(struct udphdr)); in gtp1u_handle_echo_resp()
719 /* 3GPP TS 29.281 5.1 - For the Echo Request, Echo Response, in gtp1u_handle_echo_resp()
723 if (!(gtp1u->flags & GTP1_F_SEQ) || gtp1u->tid) in gtp1u_handle_echo_resp()
724 return -1; in gtp1u_handle_echo_resp()
727 echo.ms.addr.s_addr = iph->daddr; in gtp1u_handle_echo_resp()
728 echo.peer.addr.s_addr = iph->saddr; in gtp1u_handle_echo_resp()
729 echo.gtp_version = GTP_V1; in gtp1u_handle_echo_resp()
733 return -ENOMEM; in gtp1u_handle_echo_resp()
735 ret = gtp_genl_fill_echo(msg, 0, 0, 0, GTP_CMD_ECHOREQ, echo); in gtp1u_handle_echo_resp()
741 return genlmsg_multicast_netns(>p_genl_family, dev_net(gtp->dev), in gtp1u_handle_echo_resp()
762 if (!gtp_exthdr || !gtp_exthdr->len) in gtp_parse_exthdrs()
763 return -1; in gtp_parse_exthdrs()
765 offset += gtp_exthdr->len * 4; in gtp_parse_exthdrs()
770 next_type = skb_header_pointer(skb, offset - 1, in gtp_parse_exthdrs()
773 return -1; in gtp_parse_exthdrs()
791 return -1; in gtp1u_udp_encap_recv()
793 gtp1 = (struct gtp1_header *)(skb->data + sizeof(struct udphdr)); in gtp1u_udp_encap_recv()
795 if ((gtp1->flags >> 5) != GTP_V1) in gtp1u_udp_encap_recv()
800 * handle echo request. in gtp1u_udp_encap_recv()
802 if (gtp1->type == GTP_ECHO_REQ && gtp->sk_created) in gtp1u_udp_encap_recv()
805 if (gtp1->type == GTP_ECHO_RSP && gtp->sk_created) in gtp1u_udp_encap_recv()
808 if (gtp1->type != GTP_TPDU) in gtp1u_udp_encap_recv()
817 if (gtp1->flags & GTP1_F_MASK) in gtp1u_udp_encap_recv()
822 return -1; in gtp1u_udp_encap_recv()
825 netdev_dbg(gtp->dev, "GTP packet does not encapsulate an IP packet\n"); in gtp1u_udp_encap_recv()
826 return -1; in gtp1u_udp_encap_recv()
829 gtp1 = (struct gtp1_header *)(skb->data + sizeof(struct udphdr)); in gtp1u_udp_encap_recv()
831 pctx = gtp1_pdp_find(gtp, ntohl(gtp1->tid), in gtp1u_udp_encap_recv()
834 netdev_dbg(gtp->dev, "No PDP ctx to decap skb=%p\n", skb); in gtp1u_udp_encap_recv()
838 if (gtp1->flags & GTP1_F_EXTHDR && in gtp1u_udp_encap_recv()
840 return -1; in gtp1u_udp_encap_recv()
842 return gtp_rx(pctx, skb, hdrlen, gtp->role, inner_proto); in gtp1u_udp_encap_recv()
850 gtp = sk->sk_user_data; in __gtp_encap_destroy()
852 if (gtp->sk0 == sk) in __gtp_encap_destroy()
853 gtp->sk0 = NULL; in __gtp_encap_destroy()
855 gtp->sk1u = NULL; in __gtp_encap_destroy()
856 WRITE_ONCE(udp_sk(sk)->encap_type, 0); in __gtp_encap_destroy()
882 if (gtp->sk_created) { in gtp_encap_disable()
883 udp_tunnel_sock_release(gtp->sk0->sk_socket); in gtp_encap_disable()
884 udp_tunnel_sock_release(gtp->sk1u->sk_socket); in gtp_encap_disable()
885 gtp->sk_created = false; in gtp_encap_disable()
886 gtp->sk0 = NULL; in gtp_encap_disable()
887 gtp->sk1u = NULL; in gtp_encap_disable()
889 gtp_encap_disable_sock(gtp->sk0); in gtp_encap_disable()
890 gtp_encap_disable_sock(gtp->sk1u); in gtp_encap_disable()
906 netdev_dbg(gtp->dev, "encap_recv sk=%p\n", sk); in gtp_encap_recv()
908 switch (READ_ONCE(udp_sk(sk)->encap_type)) { in gtp_encap_recv()
910 netdev_dbg(gtp->dev, "received GTP0 packet\n"); in gtp_encap_recv()
914 netdev_dbg(gtp->dev, "received GTP1U packet\n"); in gtp_encap_recv()
918 ret = -1; /* Shouldn't happen. */ in gtp_encap_recv()
923 netdev_dbg(gtp->dev, "pass up to the process\n"); in gtp_encap_recv()
927 case -1: in gtp_encap_recv()
928 netdev_dbg(gtp->dev, "GTP packet has been dropped\n"); in gtp_encap_recv()
946 int payload_len = skb->len; in gtp0_push_header()
951 gtp0->flags = 0x1e; /* v0, GTP-non-prime. */ in gtp0_push_header()
952 gtp0->type = GTP_TPDU; in gtp0_push_header()
953 gtp0->length = htons(payload_len); in gtp0_push_header()
954 gtp0->seq = htons((atomic_inc_return(&pctx->tx_seq) - 1) % 0xffff); in gtp0_push_header()
955 gtp0->flow = htons(pctx->u.v0.flow); in gtp0_push_header()
956 gtp0->number = 0xff; in gtp0_push_header()
957 gtp0->spare[0] = gtp0->spare[1] = gtp0->spare[2] = 0xff; in gtp0_push_header()
958 gtp0->tid = cpu_to_be64(pctx->u.v0.tid); in gtp0_push_header()
963 int payload_len = skb->len; in gtp1_push_header()
969 * +--+--+--+--+--+--+--+--+ in gtp1_push_header()
971 * +--+--+--+--+--+--+--+--+ in gtp1_push_header()
974 gtp1->flags = 0x30; /* v1, GTP-non-prime. */ in gtp1_push_header()
975 gtp1->type = GTP_TPDU; in gtp1_push_header()
976 gtp1->length = htons(payload_len); in gtp1_push_header()
977 gtp1->tid = htonl(pctx->u.v1.o_tei); in gtp1_push_header()
979 /* TODO: Support for extension header, sequence number and N-PDU. in gtp1_push_header()
1002 switch (pktinfo->pctx->gtp_version) { in gtp_push_header()
1004 pktinfo->gtph_port = htons(GTP0_PORT); in gtp_push_header()
1005 gtp0_push_header(skb, pktinfo->pctx); in gtp_push_header()
1008 pktinfo->gtph_port = htons(GTP1U_PORT); in gtp_push_header()
1009 gtp1_push_header(skb, pktinfo->pctx); in gtp_push_header()
1020 pktinfo->sk = sk; in gtp_set_pktinfo_ipv4()
1021 pktinfo->tos = tos; in gtp_set_pktinfo_ipv4()
1022 pktinfo->pctx = pctx; in gtp_set_pktinfo_ipv4()
1023 pktinfo->rt = rt; in gtp_set_pktinfo_ipv4()
1024 pktinfo->fl4 = *fl4; in gtp_set_pktinfo_ipv4()
1025 pktinfo->dev = dev; in gtp_set_pktinfo_ipv4()
1034 pktinfo->sk = sk; in gtp_set_pktinfo_ipv6()
1035 pktinfo->tos = tos; in gtp_set_pktinfo_ipv6()
1036 pktinfo->pctx = pctx; in gtp_set_pktinfo_ipv6()
1037 pktinfo->rt6 = rt6; in gtp_set_pktinfo_ipv6()
1038 pktinfo->fl6 = *fl6; in gtp_set_pktinfo_ipv6()
1039 pktinfo->dev = dev; in gtp_set_pktinfo_ipv6()
1052 rt = ip4_route_output_gtp(&fl4, pctx->sk, pctx->peer.addr.s_addr, in gtp_build_skb_outer_ip4()
1053 inet_sk(pctx->sk)->inet_saddr); in gtp_build_skb_outer_ip4()
1056 &pctx->peer.addr.s_addr); in gtp_build_skb_outer_ip4()
1057 dev->stats.tx_carrier_errors++; in gtp_build_skb_outer_ip4()
1061 if (rt->dst.dev == dev) { in gtp_build_skb_outer_ip4()
1063 &pctx->peer.addr.s_addr); in gtp_build_skb_outer_ip4()
1064 dev->stats.collisions++; in gtp_build_skb_outer_ip4()
1071 mtu = dst_mtu(&rt->dst) - dev->hard_header_len - in gtp_build_skb_outer_ip4()
1072 sizeof(struct iphdr) - sizeof(struct udphdr); in gtp_build_skb_outer_ip4()
1073 switch (pctx->gtp_version) { in gtp_build_skb_outer_ip4()
1075 mtu -= sizeof(struct gtp0_header); in gtp_build_skb_outer_ip4()
1078 mtu -= sizeof(struct gtp1_header); in gtp_build_skb_outer_ip4()
1082 mtu = dst_mtu(&rt->dst); in gtp_build_skb_outer_ip4()
1088 ((!skb_is_gso(skb) && skb->len > mtu) || in gtp_build_skb_outer_ip4()
1096 gtp_set_pktinfo_ipv4(pktinfo, pctx->sk, tos, pctx, rt, &fl4, dev); in gtp_build_skb_outer_ip4()
1103 return -EBADMSG; in gtp_build_skb_outer_ip4()
1116 rt = ip6_route_output_gtp(net, &fl6, pctx->sk, &pctx->peer.addr6, in gtp_build_skb_outer_ip6()
1117 &inet6_sk(pctx->sk)->saddr); in gtp_build_skb_outer_ip6()
1120 &pctx->peer.addr6); in gtp_build_skb_outer_ip6()
1121 dev->stats.tx_carrier_errors++; in gtp_build_skb_outer_ip6()
1124 dst = &rt->dst; in gtp_build_skb_outer_ip6()
1126 if (rt->dst.dev == dev) { in gtp_build_skb_outer_ip6()
1128 &pctx->peer.addr6); in gtp_build_skb_outer_ip6()
1129 dev->stats.collisions++; in gtp_build_skb_outer_ip6()
1133 mtu = dst_mtu(&rt->dst) - dev->hard_header_len - in gtp_build_skb_outer_ip6()
1134 sizeof(struct ipv6hdr) - sizeof(struct udphdr); in gtp_build_skb_outer_ip6()
1135 switch (pctx->gtp_version) { in gtp_build_skb_outer_ip6()
1137 mtu -= sizeof(struct gtp0_header); in gtp_build_skb_outer_ip6()
1140 mtu -= sizeof(struct gtp1_header); in gtp_build_skb_outer_ip6()
1146 if ((!skb_is_gso(skb) && skb->len > mtu) || in gtp_build_skb_outer_ip6()
1153 gtp_set_pktinfo_ipv6(pktinfo, pctx->sk, tos, pctx, rt, &fl6, dev); in gtp_build_skb_outer_ip6()
1160 return -EBADMSG; in gtp_build_skb_outer_ip6()
1167 struct net *net = gtp->net; in gtp_build_skb_ip4()
1176 if (gtp->role == GTP_ROLE_SGSN) in gtp_build_skb_ip4()
1177 pctx = ipv4_pdp_find(gtp, iph->saddr); in gtp_build_skb_ip4()
1179 pctx = ipv4_pdp_find(gtp, iph->daddr); in gtp_build_skb_ip4()
1183 &iph->daddr); in gtp_build_skb_ip4()
1184 return -ENOENT; in gtp_build_skb_ip4()
1188 switch (pctx->sk->sk_family) { in gtp_build_skb_ip4()
1191 iph->tos, iph->frag_off); in gtp_build_skb_ip4()
1195 iph->tos); in gtp_build_skb_ip4()
1198 ret = -1; in gtp_build_skb_ip4()
1206 netdev_dbg(dev, "gtp -> IP src: %pI4 dst: %pI4\n", in gtp_build_skb_ip4()
1207 &iph->saddr, &iph->daddr); in gtp_build_skb_ip4()
1216 struct net *net = gtp->net; in gtp_build_skb_ip6()
1226 if (gtp->role == GTP_ROLE_SGSN) in gtp_build_skb_ip6()
1227 pctx = ipv6_pdp_find(gtp, &ip6h->saddr); in gtp_build_skb_ip6()
1229 pctx = ipv6_pdp_find(gtp, &ip6h->daddr); in gtp_build_skb_ip6()
1233 &ip6h->daddr); in gtp_build_skb_ip6()
1234 return -ENOENT; in gtp_build_skb_ip6()
1240 switch (pctx->sk->sk_family) { in gtp_build_skb_ip6()
1248 ret = -1; in gtp_build_skb_ip6()
1256 netdev_dbg(dev, "gtp -> IP src: %pI6 dst: %pI6\n", in gtp_build_skb_ip6()
1257 &ip6h->saddr, &ip6h->daddr); in gtp_build_skb_ip6()
1264 unsigned int proto = ntohs(skb->protocol); in gtp_dev_xmit()
1269 if (skb_cow_head(skb, dev->needed_headroom)) in gtp_dev_xmit()
1277 /* PDP context lookups in gtp_build_skb_*() need rcu read-side lock. */ in gtp_dev_xmit()
1287 err = -EOPNOTSUPP; in gtp_dev_xmit()
1295 switch (pktinfo.pctx->sk->sk_family) { in gtp_dev_xmit()
1300 ip4_dst_hoplimit(&pktinfo.rt->dst), in gtp_dev_xmit()
1303 !net_eq(sock_net(pktinfo.pctx->sk), in gtp_dev_xmit()
1309 udp_tunnel6_xmit_skb(&pktinfo.rt6->dst, pktinfo.sk, skb, dev, in gtp_dev_xmit()
1312 ip6_dst_hoplimit(&pktinfo.rt->dst), in gtp_dev_xmit()
1324 dev->stats.tx_errors++; in gtp_dev_xmit()
1345 dev->netdev_ops = >p_netdev_ops; in gtp_link_setup()
1346 dev->needs_free_netdev = true; in gtp_link_setup()
1349 dev->hard_header_len = 0; in gtp_link_setup()
1350 dev->addr_len = 0; in gtp_link_setup()
1351 dev->mtu = ETH_DATA_LEN - GTP_IPV4_MAXLEN; in gtp_link_setup()
1354 dev->type = ARPHRD_NONE; in gtp_link_setup()
1355 dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; in gtp_link_setup()
1357 dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; in gtp_link_setup()
1358 dev->priv_flags |= IFF_NO_QUEUE; in gtp_link_setup()
1359 dev->lltx = true; in gtp_link_setup()
1362 dev->needed_headroom = LL_MAX_HEADER + GTP_IPV4_MAXLEN; in gtp_link_setup()
1363 gtp->dev = dev; in gtp_link_setup()
1373 kfree(gtp->addr_hash); in gtp_destructor()
1374 kfree(gtp->tid_hash); in gtp_destructor()
1380 udp_conf->family = family; in gtp_sock_udp_config()
1382 switch (udp_conf->family) { in gtp_sock_udp_config()
1384 udp_conf->local_ip.s_addr = nla_get_be32(nla); in gtp_sock_udp_config()
1388 udp_conf->local_ip6 = nla_get_in6_addr(nla); in gtp_sock_udp_config()
1392 return -EOPNOTSUPP; in gtp_sock_udp_config()
1403 struct net *net = gtp->net; in gtp_create_sock()
1421 return ERR_PTR(-EINVAL); in gtp_create_sock()
1434 return sock->sk; in gtp_create_sock()
1449 udp_tunnel_sock_release(sk0->sk_socket); in gtp_create_sockets()
1453 gtp->sk_created = true; in gtp_create_sockets()
1454 gtp->sk0 = sk0; in gtp_create_sockets()
1455 gtp->sk1u = sk1u; in gtp_create_sockets()
1474 return -EAFNOSUPPORT; in gtp_newlink()
1490 return -EINVAL; in gtp_newlink()
1492 gtp->role = role; in gtp_newlink()
1494 gtp->restart_count = nla_get_u8_default(data[IFLA_GTP_RESTART_COUNT], in gtp_newlink()
1497 gtp->net = src_net; in gtp_newlink()
1515 if ((gtp->sk0 && gtp->sk0->sk_family == AF_INET6) || in gtp_newlink()
1516 (gtp->sk1u && gtp->sk1u->sk_family == AF_INET6)) { in gtp_newlink()
1517 dev->mtu = ETH_DATA_LEN - GTP_IPV6_MAXLEN; in gtp_newlink()
1518 dev->needed_headroom = LL_MAX_HEADER + GTP_IPV6_MAXLEN; in gtp_newlink()
1528 list_add_rcu(>p->list, &gn->gtp_dev_list); in gtp_newlink()
1529 dev->priv_destructor = gtp_destructor; in gtp_newlink()
1538 kfree(gtp->addr_hash); in gtp_newlink()
1539 kfree(gtp->tid_hash); in gtp_newlink()
1550 for (i = 0; i < gtp->hash_size; i++) in gtp_dellink()
1551 hlist_for_each_entry_safe(pctx, next, >p->tid_hash[i], hlist_tid) in gtp_dellink()
1554 list_del_rcu(>p->list); in gtp_dellink()
1573 return -EINVAL; in gtp_validate()
1589 if (nla_put_u32(skb, IFLA_GTP_PDP_HASHSIZE, gtp->hash_size)) in gtp_fill_info()
1591 if (nla_put_u32(skb, IFLA_GTP_ROLE, gtp->role)) in gtp_fill_info()
1593 if (nla_put_u8(skb, IFLA_GTP_RESTART_COUNT, gtp->restart_count)) in gtp_fill_info()
1599 return -EMSGSIZE; in gtp_fill_info()
1619 gtp->addr_hash = kmalloc_array(hsize, sizeof(struct hlist_head), in gtp_hashtable_new()
1621 if (gtp->addr_hash == NULL) in gtp_hashtable_new()
1622 return -ENOMEM; in gtp_hashtable_new()
1624 gtp->tid_hash = kmalloc_array(hsize, sizeof(struct hlist_head), in gtp_hashtable_new()
1626 if (gtp->tid_hash == NULL) in gtp_hashtable_new()
1629 gtp->hash_size = hsize; in gtp_hashtable_new()
1632 INIT_HLIST_HEAD(>p->addr_hash[i]); in gtp_hashtable_new()
1633 INIT_HLIST_HEAD(>p->tid_hash[i]); in gtp_hashtable_new()
1637 kfree(gtp->addr_hash); in gtp_hashtable_new()
1638 return -ENOMEM; in gtp_hashtable_new()
1657 sk = sock->sk; in gtp_encap_enable_socket()
1658 if (sk->sk_protocol != IPPROTO_UDP || in gtp_encap_enable_socket()
1659 sk->sk_type != SOCK_DGRAM || in gtp_encap_enable_socket()
1660 (sk->sk_family != AF_INET && sk->sk_family != AF_INET6)) { in gtp_encap_enable_socket()
1662 sk = ERR_PTR(-EINVAL); in gtp_encap_enable_socket()
1666 if (sk->sk_family == AF_INET6 && in gtp_encap_enable_socket()
1667 !sk->sk_ipv6only) { in gtp_encap_enable_socket()
1668 sk = ERR_PTR(-EADDRNOTAVAIL); in gtp_encap_enable_socket()
1673 if (sk->sk_user_data) { in gtp_encap_enable_socket()
1674 sk = ERR_PTR(-EBUSY); in gtp_encap_enable_socket()
1685 setup_udp_tunnel_sock(sock_net(sock->sk), sock, &tuncfg); in gtp_encap_enable_socket()
1688 release_sock(sock->sk); in gtp_encap_enable_socket()
1700 return -EINVAL; in gtp_encap_enable()
1724 gtp->sk0 = sk0; in gtp_encap_enable()
1725 gtp->sk1u = sk1u; in gtp_encap_enable()
1728 sk0->sk_family != sk1u->sk_family) { in gtp_encap_enable()
1731 return -EINVAL; in gtp_encap_enable()
1756 if (dev && dev->netdev_ops == >p_netdev_ops) in gtp_find_dev()
1765 pctx->gtp_version = nla_get_u32(info->attrs[GTPA_VERSION]); in gtp_pdp_fill()
1767 switch (pctx->gtp_version) { in gtp_pdp_fill()
1773 pctx->u.v0.tid = nla_get_u64(info->attrs[GTPA_TID]); in gtp_pdp_fill()
1774 pctx->u.v0.flow = nla_get_u16(info->attrs[GTPA_FLOW]); in gtp_pdp_fill()
1777 pctx->u.v1.i_tei = nla_get_u32(info->attrs[GTPA_I_TEI]); in gtp_pdp_fill()
1778 pctx->u.v1.o_tei = nla_get_u32(info->attrs[GTPA_O_TEI]); in gtp_pdp_fill()
1787 if (info->attrs[GTPA_PEER_ADDRESS]) { in ip_pdp_peer_fill()
1788 pctx->peer.addr.s_addr = in ip_pdp_peer_fill()
1789 nla_get_be32(info->attrs[GTPA_PEER_ADDRESS]); in ip_pdp_peer_fill()
1790 } else if (info->attrs[GTPA_PEER_ADDR6]) { in ip_pdp_peer_fill()
1791 pctx->peer.addr6 = nla_get_in6_addr(info->attrs[GTPA_PEER_ADDR6]); in ip_pdp_peer_fill()
1798 pctx->ms.addr.s_addr = in ipv4_pdp_fill()
1799 nla_get_be32(info->attrs[GTPA_MS_ADDRESS]); in ipv4_pdp_fill()
1806 pctx->ms.addr6 = nla_get_in6_addr(info->attrs[GTPA_MS_ADDR6]); in ipv6_pdp_fill()
1807 if (pctx->ms.addr6.s6_addr32[2] || in ipv6_pdp_fill()
1808 pctx->ms.addr6.s6_addr32[3]) in ipv6_pdp_fill()
1820 struct net_device *dev = gtp->dev; in gtp_pdp_add()
1828 version = nla_get_u32(info->attrs[GTPA_VERSION]); in gtp_pdp_add()
1830 family = nla_get_u8_default(info->attrs[GTPA_FAMILY], AF_INET); in gtp_pdp_add()
1834 return ERR_PTR(-EAFNOSUPPORT); in gtp_pdp_add()
1836 if (!info->attrs[GTPA_PEER_ADDRESS] && in gtp_pdp_add()
1837 !info->attrs[GTPA_PEER_ADDR6]) in gtp_pdp_add()
1838 return ERR_PTR(-EINVAL); in gtp_pdp_add()
1840 if ((info->attrs[GTPA_PEER_ADDRESS] && in gtp_pdp_add()
1841 sk->sk_family == AF_INET6) || in gtp_pdp_add()
1842 (info->attrs[GTPA_PEER_ADDR6] && in gtp_pdp_add()
1843 sk->sk_family == AF_INET)) in gtp_pdp_add()
1844 return ERR_PTR(-EAFNOSUPPORT); in gtp_pdp_add()
1848 if (!info->attrs[GTPA_MS_ADDRESS] || in gtp_pdp_add()
1849 info->attrs[GTPA_MS_ADDR6]) in gtp_pdp_add()
1850 return ERR_PTR(-EINVAL); in gtp_pdp_add()
1852 ms_addr = nla_get_be32(info->attrs[GTPA_MS_ADDRESS]); in gtp_pdp_add()
1853 hash_ms = ipv4_hashfn(ms_addr) % gtp->hash_size; in gtp_pdp_add()
1857 if (!info->attrs[GTPA_MS_ADDR6] || in gtp_pdp_add()
1858 info->attrs[GTPA_MS_ADDRESS]) in gtp_pdp_add()
1859 return ERR_PTR(-EINVAL); in gtp_pdp_add()
1861 ms_addr6 = nla_get_in6_addr(info->attrs[GTPA_MS_ADDR6]); in gtp_pdp_add()
1862 hash_ms = ipv6_hashfn(&ms_addr6) % gtp->hash_size; in gtp_pdp_add()
1866 return ERR_PTR(-EAFNOSUPPORT); in gtp_pdp_add()
1872 nla_get_u64(info->attrs[GTPA_TID]), in gtp_pdp_add()
1876 nla_get_u32(info->attrs[GTPA_I_TEI]), in gtp_pdp_add()
1882 if (info->nlhdr->nlmsg_flags & NLM_F_EXCL) in gtp_pdp_add()
1883 return ERR_PTR(-EEXIST); in gtp_pdp_add()
1884 if (info->nlhdr->nlmsg_flags & NLM_F_REPLACE) in gtp_pdp_add()
1885 return ERR_PTR(-EOPNOTSUPP); in gtp_pdp_add()
1888 return ERR_PTR(-EEXIST); in gtp_pdp_add()
1892 switch (pctx->af) { in gtp_pdp_add()
1898 return ERR_PTR(-EADDRNOTAVAIL); in gtp_pdp_add()
1902 if (pctx->gtp_version == GTP_V0) in gtp_pdp_add()
1903 netdev_dbg(dev, "GTPv0-U: update tunnel id = %llx (pdp %p)\n", in gtp_pdp_add()
1904 pctx->u.v0.tid, pctx); in gtp_pdp_add()
1905 else if (pctx->gtp_version == GTP_V1) in gtp_pdp_add()
1906 netdev_dbg(dev, "GTPv1-U: update tunnel id = %x/%x (pdp %p)\n", in gtp_pdp_add()
1907 pctx->u.v1.i_tei, pctx->u.v1.o_tei, pctx); in gtp_pdp_add()
1915 return ERR_PTR(-ENOMEM); in gtp_pdp_add()
1918 pctx->sk = sk; in gtp_pdp_add()
1919 pctx->dev = gtp->dev; in gtp_pdp_add()
1920 pctx->af = family; in gtp_pdp_add()
1922 switch (pctx->af) { in gtp_pdp_add()
1924 if (!info->attrs[GTPA_MS_ADDRESS]) { in gtp_pdp_add()
1927 return ERR_PTR(-EINVAL); in gtp_pdp_add()
1933 if (!info->attrs[GTPA_MS_ADDR6]) { in gtp_pdp_add()
1936 return ERR_PTR(-EINVAL); in gtp_pdp_add()
1942 return ERR_PTR(-EADDRNOTAVAIL); in gtp_pdp_add()
1946 atomic_set(&pctx->tx_seq, 0); in gtp_pdp_add()
1948 switch (pctx->gtp_version) { in gtp_pdp_add()
1955 hash_tid = gtp0_hashfn(pctx->u.v0.tid) % gtp->hash_size; in gtp_pdp_add()
1958 hash_tid = gtp1u_hashfn(pctx->u.v1.i_tei) % gtp->hash_size; in gtp_pdp_add()
1962 hlist_add_head_rcu(&pctx->hlist_addr, >p->addr_hash[hash_ms]); in gtp_pdp_add()
1963 hlist_add_head_rcu(&pctx->hlist_tid, >p->tid_hash[hash_tid]); in gtp_pdp_add()
1965 switch (pctx->gtp_version) { in gtp_pdp_add()
1967 netdev_dbg(dev, "GTPv0-U: new PDP ctx id=%llx ssgn=%pI4 ms=%pI4 (pdp=%p)\n", in gtp_pdp_add()
1968 pctx->u.v0.tid, &pctx->peer.addr, in gtp_pdp_add()
1969 &pctx->ms.addr, pctx); in gtp_pdp_add()
1972 netdev_dbg(dev, "GTPv1-U: new PDP ctx id=%x/%x ssgn=%pI4 ms=%pI4 (pdp=%p)\n", in gtp_pdp_add()
1973 pctx->u.v1.i_tei, pctx->u.v1.o_tei, in gtp_pdp_add()
1974 &pctx->peer.addr, &pctx->ms.addr, pctx); in gtp_pdp_add()
1985 sock_put(pctx->sk); in pdp_context_free()
1991 hlist_del_rcu(&pctx->hlist_tid); in pdp_context_delete()
1992 hlist_del_rcu(&pctx->hlist_addr); in pdp_context_delete()
1993 call_rcu(&pctx->rcu_head, pdp_context_free); in pdp_context_delete()
2006 if (!info->attrs[GTPA_VERSION] || in gtp_genl_new_pdp()
2007 !info->attrs[GTPA_LINK]) in gtp_genl_new_pdp()
2008 return -EINVAL; in gtp_genl_new_pdp()
2010 version = nla_get_u32(info->attrs[GTPA_VERSION]); in gtp_genl_new_pdp()
2014 if (!info->attrs[GTPA_TID] || in gtp_genl_new_pdp()
2015 !info->attrs[GTPA_FLOW]) in gtp_genl_new_pdp()
2016 return -EINVAL; in gtp_genl_new_pdp()
2019 if (!info->attrs[GTPA_I_TEI] || in gtp_genl_new_pdp()
2020 !info->attrs[GTPA_O_TEI]) in gtp_genl_new_pdp()
2021 return -EINVAL; in gtp_genl_new_pdp()
2025 return -EINVAL; in gtp_genl_new_pdp()
2030 gtp = gtp_find_dev(sock_net(skb->sk), info->attrs); in gtp_genl_new_pdp()
2032 err = -ENODEV; in gtp_genl_new_pdp()
2037 sk = gtp->sk0; in gtp_genl_new_pdp()
2039 sk = gtp->sk1u; in gtp_genl_new_pdp()
2044 err = -ENODEV; in gtp_genl_new_pdp()
2071 return ERR_PTR(-ENODEV); in gtp_find_pdp_by_link()
2077 return ERR_PTR(-EINVAL); in gtp_find_pdp_by_link()
2084 return ERR_PTR(-EINVAL); in gtp_find_pdp_by_link()
2088 return ERR_PTR(-EADDRNOTAVAIL); in gtp_find_pdp_by_link()
2103 return ERR_PTR(-EINVAL); in gtp_find_pdp_by_link()
2113 pctx = ERR_PTR(-EINVAL); in gtp_find_pdp()
2116 pctx = ERR_PTR(-ENOENT); in gtp_find_pdp()
2126 if (!info->attrs[GTPA_VERSION]) in gtp_genl_del_pdp()
2127 return -EINVAL; in gtp_genl_del_pdp()
2131 pctx = gtp_find_pdp(sock_net(skb->sk), info->attrs); in gtp_genl_del_pdp()
2137 if (pctx->gtp_version == GTP_V0) in gtp_genl_del_pdp()
2138 netdev_dbg(pctx->dev, "GTPv0-U: deleting tunnel id = %llx (pdp %p)\n", in gtp_genl_del_pdp()
2139 pctx->u.v0.tid, pctx); in gtp_genl_del_pdp()
2140 else if (pctx->gtp_version == GTP_V1) in gtp_genl_del_pdp()
2141 netdev_dbg(pctx->dev, "GTPv1-U: deleting tunnel id = %x/%x (pdp %p)\n", in gtp_genl_del_pdp()
2142 pctx->u.v1.i_tei, pctx->u.v1.o_tei, pctx); in gtp_genl_del_pdp()
2162 if (nla_put_u32(skb, GTPA_VERSION, pctx->gtp_version) || in gtp_genl_fill_info()
2163 nla_put_u32(skb, GTPA_LINK, pctx->dev->ifindex) || in gtp_genl_fill_info()
2164 nla_put_u8(skb, GTPA_FAMILY, pctx->af)) in gtp_genl_fill_info()
2167 switch (pctx->af) { in gtp_genl_fill_info()
2169 if (nla_put_be32(skb, GTPA_MS_ADDRESS, pctx->ms.addr.s_addr)) in gtp_genl_fill_info()
2173 if (nla_put_in6_addr(skb, GTPA_MS_ADDR6, &pctx->ms.addr6)) in gtp_genl_fill_info()
2178 switch (pctx->sk->sk_family) { in gtp_genl_fill_info()
2180 if (nla_put_be32(skb, GTPA_PEER_ADDRESS, pctx->peer.addr.s_addr)) in gtp_genl_fill_info()
2184 if (nla_put_in6_addr(skb, GTPA_PEER_ADDR6, &pctx->peer.addr6)) in gtp_genl_fill_info()
2189 switch (pctx->gtp_version) { in gtp_genl_fill_info()
2191 if (nla_put_u64_64bit(skb, GTPA_TID, pctx->u.v0.tid, GTPA_PAD) || in gtp_genl_fill_info()
2192 nla_put_u16(skb, GTPA_FLOW, pctx->u.v0.flow)) in gtp_genl_fill_info()
2196 if (nla_put_u32(skb, GTPA_I_TEI, pctx->u.v1.i_tei) || in gtp_genl_fill_info()
2197 nla_put_u32(skb, GTPA_O_TEI, pctx->u.v1.o_tei)) in gtp_genl_fill_info()
2207 return -EMSGSIZE; in gtp_genl_fill_info()
2217 return -ENOMEM; in gtp_tunnel_notify()
2225 ret = genlmsg_multicast_netns(>p_genl_family, dev_net(pctx->dev), msg, in gtp_tunnel_notify()
2236 if (!info->attrs[GTPA_VERSION]) in gtp_genl_get_pdp()
2237 return -EINVAL; in gtp_genl_get_pdp()
2241 pctx = gtp_find_pdp(sock_net(skb->sk), info->attrs); in gtp_genl_get_pdp()
2249 err = -ENOMEM; in gtp_genl_get_pdp()
2253 err = gtp_genl_fill_info(skb2, NETLINK_CB(skb).portid, info->snd_seq, in gtp_genl_get_pdp()
2254 0, info->nlhdr->nlmsg_type, pctx); in gtp_genl_get_pdp()
2259 return genlmsg_unicast(genl_info_net(info), skb2, info->snd_portid); in gtp_genl_get_pdp()
2271 struct gtp_dev *last_gtp = (struct gtp_dev *)cb->args[2], *gtp; in gtp_genl_dump_pdp()
2272 int i, j, bucket = cb->args[0], skip = cb->args[1]; in gtp_genl_dump_pdp()
2273 struct net *net = sock_net(skb->sk); in gtp_genl_dump_pdp()
2279 if (cb->args[4]) in gtp_genl_dump_pdp()
2283 list_for_each_entry_rcu(gtp, &gn->gtp_dev_list, list) { in gtp_genl_dump_pdp()
2289 for (i = bucket; i < gtp->hash_size; i++) { in gtp_genl_dump_pdp()
2291 hlist_for_each_entry_rcu(pctx, >p->tid_hash[i], in gtp_genl_dump_pdp()
2295 NETLINK_CB(cb->skb).portid, in gtp_genl_dump_pdp()
2296 cb->nlh->nlmsg_seq, in gtp_genl_dump_pdp()
2298 cb->nlh->nlmsg_type, pctx)) { in gtp_genl_dump_pdp()
2299 cb->args[0] = i; in gtp_genl_dump_pdp()
2300 cb->args[1] = j; in gtp_genl_dump_pdp()
2301 cb->args[2] = (unsigned long)gtp; in gtp_genl_dump_pdp()
2310 cb->args[4] = 1; in gtp_genl_dump_pdp()
2313 return skb->len; in gtp_genl_dump_pdp()
2328 if (!info->attrs[GTPA_VERSION] || in gtp_genl_send_echo_req()
2329 !info->attrs[GTPA_LINK] || in gtp_genl_send_echo_req()
2330 !info->attrs[GTPA_PEER_ADDRESS] || in gtp_genl_send_echo_req()
2331 !info->attrs[GTPA_MS_ADDRESS]) in gtp_genl_send_echo_req()
2332 return -EINVAL; in gtp_genl_send_echo_req()
2334 version = nla_get_u32(info->attrs[GTPA_VERSION]); in gtp_genl_send_echo_req()
2335 dst_ip = nla_get_be32(info->attrs[GTPA_PEER_ADDRESS]); in gtp_genl_send_echo_req()
2336 src_ip = nla_get_be32(info->attrs[GTPA_MS_ADDRESS]); in gtp_genl_send_echo_req()
2338 gtp = gtp_find_dev(sock_net(skb->sk), info->attrs); in gtp_genl_send_echo_req()
2340 return -ENODEV; in gtp_genl_send_echo_req()
2342 if (!gtp->sk_created) in gtp_genl_send_echo_req()
2343 return -EOPNOTSUPP; in gtp_genl_send_echo_req()
2344 if (!(gtp->dev->flags & IFF_UP)) in gtp_genl_send_echo_req()
2345 return -ENETDOWN; in gtp_genl_send_echo_req()
2350 len = LL_RESERVED_SPACE(gtp->dev) + sizeof(struct gtp0_header) + in gtp_genl_send_echo_req()
2353 skb_to_send = netdev_alloc_skb_ip_align(gtp->dev, len); in gtp_genl_send_echo_req()
2355 return -ENOMEM; in gtp_genl_send_echo_req()
2357 sk = gtp->sk0; in gtp_genl_send_echo_req()
2366 len = LL_RESERVED_SPACE(gtp->dev) + in gtp_genl_send_echo_req()
2370 skb_to_send = netdev_alloc_skb_ip_align(gtp->dev, len); in gtp_genl_send_echo_req()
2372 return -ENOMEM; in gtp_genl_send_echo_req()
2374 sk = gtp->sk1u; in gtp_genl_send_echo_req()
2382 return -ENODEV; in gtp_genl_send_echo_req()
2387 netdev_dbg(gtp->dev, "no route for echo request to %pI4\n", in gtp_genl_send_echo_req()
2390 return -ENODEV; in gtp_genl_send_echo_req()
2396 ip4_dst_hoplimit(&rt->dst), in gtp_genl_send_echo_req()
2400 dev_net(gtp->dev)), in gtp_genl_send_echo_req()
2467 INIT_LIST_HEAD(&gn->gtp_dev_list); in gtp_net_init()
2480 list_for_each_entry(gtp, &gn->gtp_dev_list, list) in gtp_net_exit_batch_rtnl()
2481 gtp_dellink(gtp->dev, dev_to_kill); in gtp_net_exit_batch_rtnl()