• Home
  • Raw
  • Download

Lines Matching refs:gtp

109 static struct pdp_ctx *gtp0_pdp_find(struct gtp_dev *gtp, u64 tid)  in gtp0_pdp_find()  argument
114 head = &gtp->tid_hash[gtp0_hashfn(tid) % gtp->hash_size]; in gtp0_pdp_find()
125 static struct pdp_ctx *gtp1_pdp_find(struct gtp_dev *gtp, u32 tid) in gtp1_pdp_find() argument
130 head = &gtp->tid_hash[gtp1u_hashfn(tid) % gtp->hash_size]; in gtp1_pdp_find()
141 static struct pdp_ctx *ipv4_pdp_find(struct gtp_dev *gtp, __be32 ms_addr) in ipv4_pdp_find() argument
146 head = &gtp->addr_hash[ipv4_hashfn(ms_addr) % gtp->hash_size]; in ipv4_pdp_find()
222 static int gtp0_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb) in gtp0_udp_encap_recv() argument
240 pctx = gtp0_pdp_find(gtp, be64_to_cpu(gtp0->tid)); in gtp0_udp_encap_recv()
242 netdev_dbg(gtp->dev, "No PDP ctx to decap skb=%p\n", skb); in gtp0_udp_encap_recv()
246 return gtp_rx(pctx, skb, hdrlen, gtp->role); in gtp0_udp_encap_recv()
249 static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb) in gtp1u_udp_encap_recv() argument
282 pctx = gtp1_pdp_find(gtp, ntohl(gtp1->tid)); in gtp1u_udp_encap_recv()
284 netdev_dbg(gtp->dev, "No PDP ctx to decap skb=%p\n", skb); in gtp1u_udp_encap_recv()
288 return gtp_rx(pctx, skb, hdrlen, gtp->role); in gtp1u_udp_encap_recv()
293 struct gtp_dev *gtp; in __gtp_encap_destroy() local
296 gtp = sk->sk_user_data; in __gtp_encap_destroy()
297 if (gtp) { in __gtp_encap_destroy()
298 if (gtp->sk0 == sk) in __gtp_encap_destroy()
299 gtp->sk0 = NULL; in __gtp_encap_destroy()
301 gtp->sk1u = NULL; in __gtp_encap_destroy()
324 static void gtp_encap_disable(struct gtp_dev *gtp) in gtp_encap_disable() argument
326 gtp_encap_disable_sock(gtp->sk0); in gtp_encap_disable()
327 gtp_encap_disable_sock(gtp->sk1u); in gtp_encap_disable()
335 struct gtp_dev *gtp; in gtp_encap_recv() local
338 gtp = rcu_dereference_sk_user_data(sk); in gtp_encap_recv()
339 if (!gtp) in gtp_encap_recv()
342 netdev_dbg(gtp->dev, "encap_recv sk=%p\n", sk); in gtp_encap_recv()
346 netdev_dbg(gtp->dev, "received GTP0 packet\n"); in gtp_encap_recv()
347 ret = gtp0_udp_encap_recv(gtp, skb); in gtp_encap_recv()
350 netdev_dbg(gtp->dev, "received GTP1U packet\n"); in gtp_encap_recv()
351 ret = gtp1u_udp_encap_recv(gtp, skb); in gtp_encap_recv()
359 netdev_dbg(gtp->dev, "pass up to the process\n"); in gtp_encap_recv()
364 netdev_dbg(gtp->dev, "GTP packet has been dropped\n"); in gtp_encap_recv()
375 struct gtp_dev *gtp = netdev_priv(dev); in gtp_dev_init() local
377 gtp->dev = dev; in gtp_dev_init()
388 struct gtp_dev *gtp = netdev_priv(dev); in gtp_dev_uninit() local
390 gtp_encap_disable(gtp); in gtp_dev_uninit()
489 struct gtp_dev *gtp = netdev_priv(dev); in gtp_build_skb_ip4() local
501 if (gtp->role == GTP_ROLE_SGSN) in gtp_build_skb_ip4()
502 pctx = ipv4_pdp_find(gtp, iph->saddr); in gtp_build_skb_ip4()
504 pctx = ipv4_pdp_find(gtp, iph->daddr); in gtp_build_skb_ip4()
646 static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize);
647 static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[]);
651 struct gtp_dev *gtp = netdev_priv(dev); in gtp_destructor() local
653 kfree(gtp->addr_hash); in gtp_destructor()
654 kfree(gtp->tid_hash); in gtp_destructor()
661 struct gtp_dev *gtp; in gtp_newlink() local
668 gtp = netdev_priv(dev); in gtp_newlink()
670 err = gtp_encap_enable(gtp, data); in gtp_newlink()
682 err = gtp_hashtable_new(gtp, hashsize); in gtp_newlink()
693 list_add_rcu(&gtp->list, &gn->gtp_dev_list); in gtp_newlink()
701 kfree(gtp->addr_hash); in gtp_newlink()
702 kfree(gtp->tid_hash); in gtp_newlink()
704 gtp_encap_disable(gtp); in gtp_newlink()
710 struct gtp_dev *gtp = netdev_priv(dev); in gtp_dellink() local
714 for (i = 0; i < gtp->hash_size; i++) in gtp_dellink()
715 hlist_for_each_entry_rcu(pctx, &gtp->tid_hash[i], hlist_tid) in gtp_dellink()
718 gtp_encap_disable(gtp); in gtp_dellink()
719 list_del_rcu(&gtp->list); in gtp_dellink()
746 struct gtp_dev *gtp = netdev_priv(dev); in gtp_fill_info() local
748 if (nla_put_u32(skb, IFLA_GTP_PDP_HASHSIZE, gtp->hash_size)) in gtp_fill_info()
770 static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize) in gtp_hashtable_new() argument
774 gtp->addr_hash = kmalloc(sizeof(struct hlist_head) * hsize, in gtp_hashtable_new()
776 if (gtp->addr_hash == NULL) in gtp_hashtable_new()
779 gtp->tid_hash = kmalloc(sizeof(struct hlist_head) * hsize, in gtp_hashtable_new()
781 if (gtp->tid_hash == NULL) in gtp_hashtable_new()
784 gtp->hash_size = hsize; in gtp_hashtable_new()
787 INIT_HLIST_HEAD(&gtp->addr_hash[i]); in gtp_hashtable_new()
788 INIT_HLIST_HEAD(&gtp->tid_hash[i]); in gtp_hashtable_new()
792 kfree(gtp->addr_hash); in gtp_hashtable_new()
797 struct gtp_dev *gtp) in gtp_encap_enable_socket() argument
829 tuncfg.sk_user_data = gtp; in gtp_encap_enable_socket()
843 static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[]) in gtp_encap_enable() argument
852 sk0 = gtp_encap_enable_socket(fd0, UDP_ENCAP_GTP0, gtp); in gtp_encap_enable()
860 sk1u = gtp_encap_enable_socket(fd1, UDP_ENCAP_GTP1U, gtp); in gtp_encap_enable()
879 gtp->sk0 = sk0; in gtp_encap_enable()
880 gtp->sk1u = sk1u; in gtp_encap_enable()
881 gtp->role = role; in gtp_encap_enable()
888 struct gtp_dev *gtp = NULL; in gtp_find_dev() local
906 gtp = netdev_priv(dev); in gtp_find_dev()
909 return gtp; in gtp_find_dev()
939 static int gtp_pdp_add(struct gtp_dev *gtp, struct sock *sk, in gtp_pdp_add() argument
943 struct net_device *dev = gtp->dev; in gtp_pdp_add()
950 hash_ms = ipv4_hashfn(ms_addr) % gtp->hash_size; in gtp_pdp_add()
953 pctx = ipv4_pdp_find(gtp, ms_addr); in gtp_pdp_add()
957 pctx_tid = gtp0_pdp_find(gtp, in gtp_pdp_add()
960 pctx_tid = gtp1_pdp_find(gtp, in gtp_pdp_add()
995 pctx->dev = gtp->dev; in gtp_pdp_add()
1006 hash_tid = gtp0_hashfn(pctx->u.v0.tid) % gtp->hash_size; in gtp_pdp_add()
1009 hash_tid = gtp1u_hashfn(pctx->u.v1.i_tei) % gtp->hash_size; in gtp_pdp_add()
1013 hlist_add_head_rcu(&pctx->hlist_addr, &gtp->addr_hash[hash_ms]); in gtp_pdp_add()
1014 hlist_add_head_rcu(&pctx->hlist_tid, &gtp->tid_hash[hash_tid]); in gtp_pdp_add()
1050 struct gtp_dev *gtp; in gtp_genl_new_pdp() local
1081 gtp = gtp_find_dev(sock_net(skb->sk), info->attrs); in gtp_genl_new_pdp()
1082 if (!gtp) { in gtp_genl_new_pdp()
1088 sk = gtp->sk0; in gtp_genl_new_pdp()
1090 sk = gtp->sk1u; in gtp_genl_new_pdp()
1099 err = gtp_pdp_add(gtp, sk, info); in gtp_genl_new_pdp()
1110 struct gtp_dev *gtp; in gtp_find_pdp_by_link() local
1112 gtp = gtp_find_dev(net, nla); in gtp_find_pdp_by_link()
1113 if (!gtp) in gtp_find_pdp_by_link()
1119 return ipv4_pdp_find(gtp, ip); in gtp_find_pdp_by_link()
1124 return gtp0_pdp_find(gtp, nla_get_u64(nla[GTPA_TID])); in gtp_find_pdp_by_link()
1126 return gtp1_pdp_find(gtp, nla_get_u32(nla[GTPA_I_TEI])); in gtp_find_pdp_by_link()
1256 struct gtp_dev *last_gtp = (struct gtp_dev *)cb->args[2], *gtp; in gtp_genl_dump_pdp() local
1268 list_for_each_entry_rcu(gtp, &gn->gtp_dev_list, list) { in gtp_genl_dump_pdp()
1269 if (last_gtp && last_gtp != gtp) in gtp_genl_dump_pdp()
1274 for (i = bucket; i < gtp->hash_size; i++) { in gtp_genl_dump_pdp()
1276 hlist_for_each_entry_rcu(pctx, &gtp->tid_hash[i], in gtp_genl_dump_pdp()
1285 cb->args[2] = (unsigned long)gtp; in gtp_genl_dump_pdp()
1356 struct gtp_dev *gtp; in gtp_net_exit() local
1360 list_for_each_entry(gtp, &gn->gtp_dev_list, list) in gtp_net_exit()
1361 gtp_dellink(gtp->dev, &list); in gtp_net_exit()