Bug #6382
Updated by laforge 6 months ago
Pau and I debugged why TC_pdp6_act_deact_gtpu_access does not work with osmo-ggsn with kernel gtp-u. It passes without kernel gtp-u. > <pre> pespin: so I'd say that use case cannot really be performed right now as with current setup, but it's quite a specific one and not sure what would be the best desired behavior > pespin: pespin: so in summary: a GTP-U/IPv6(src-addr-link-local) arrives to the gtp kernel module (socket fd1u), and it decides the GGSN (userspace) needs to handle the packet, so the packet is pushed/read by osmo-ggsn, which in our current logic decides to forward the packet out of the tun. In order to do that, when we have a non-gtp generic tun, we use the tun FD to inject the decapsulted packet (IPv6(src-addr-link-local) into the network stack. > pespin: pespin: but when using the gtp tundev kind, we apparently do have the "tun fd" we need to inject decapsulated packets from the userspace program (osmo-ggsn), that only happens through the network stack internally. > pespin: pespin: So the question would be: 1- Can we somehow obtain an fd for the tun so we can inject decapsulated packets to it like we do in the userspace-gtp scenario? If yes, we should replace fd = -1 with that. If no, then we simply assume we don't want to inject those packets and discard them > pespin: them. pespin: feel free to create the ticket or point me to the existing one and I can fill in more info </pre> {{collapse(osmo-ggsn log + dmesg) <pre> + osmo-ggsn -c /data/osmo-ggsn.cfg 20240301163326408 DLSTATS INFO Stats timer started with interval 5 sec (stats.c:206) 20240301163326410 DGGSN INFO APN(internet): Starting (ggsn.c:186) 20240301163326411 DGGSN INFO APN(internet): Opening Kernel GTP device tun46 (ggsn.c:204) 20240301163326412 DGGSN NOTICE APN(internet): Skipping APN start (ggsn.c:210) 20240301163326413 DGGSN INFO GGSN(ggsn0): Starting GGSN (ggsn.c:816) 20240301163326414 DLGTP NOTICE GTP: gtp_newgsn() started at 172.18.70.201 (gsn.c:465) 20240301163326416 DLGTP NOTICE State information file (/tmp/gsn_restart) not found. Creating new file. (gsn.c:386) 20240301163326417 DLGLOBAL DEBUG validating counter group 0x7fd8d2ca7b00(gsn) with 18 counters (rate_ctr.c:86) 20240301163326419 DGGSN NOTICE GGSN(ggsn0): Successfully started (ggsn.c:852) 20240301163326420 DGGSN INFO APN(internet): Starting (ggsn.c:186) 20240301163326421 DGGSN INFO APN(internet): Opening Kernel GTP device tun46 (ggsn.c:204) 20240301163326422 DGGSN NOTICE Initialized GTP kernel mode (genl ID is 32) (gtp-kernel.c:79) [ 0.772102] gtp: enable gtp on 7, 4 [ 0.772475] gtp: enable gtp on 9, 5 [ 0.773067] tun46: registered new GTP interface 20240301163326425 DTUN NOTICE GTP kernel configured (tun.c:217) [ 0.774548] tun46: no PDP ctx found for ff02:0000:0000:0000:0000:0000:0000:0002, skip 20240301163326426 DGGSN INFO APN(internet): Setting tun IP address 176.16.16.0/20 (ggsn.c:230) 20240301163326428 DGGSN INFO APN(internet): Setting tun IPv6 address 2001:780:44:2100::/56 (ggsn.c:242) 20240301163326429 DGGSN INFO APN(internet): Creating IPv4 pool 176.16.16.0/20 (ggsn.c:288) 20240301163326430 DGGSN INFO APN(internet): Blacklist tun IP 176.16.16.0/20 (ggsn.c:167) 20240301163326432 DGGSN INFO APN(internet): Creating IPv6 pool 2001:780:44:2100::/56 (ggsn.c:305)[ 0.781506] tun46: no PDP ctx found for ff02:0000:0000:0000:0000:0000:0000:0016, skip 20240301163326434 DGGSN INFO APN(internet): Blacklist tun IP 2001:780:44:2100::/56 (ggsn.c:167) 20240301163326435 DGGSN NOTICE APN(internet): Successfully started (ggsn.c:320) 20240301163326436 DLGLOBAL NOTICE Available via telnet 0.0.0.0 4260 (telnet_interface.c:88) 20240301163326437 DLCTRL NOTICE CTRL at 127.0.0.1 4257 (control_if.c:1014) [ 1.166137] input: ImExPS/2 Generic Explorer Mouse as /devices/platform/i8042/serio1/input/input3 [ 1.603649] tun46: no PDP ctx found for ff02:0000:0000:0000:0000:0000:0000:0016, skip [ 1.604747] tun46: no PDP ctx found for ff02:0000:0000:0000:0000:0000:0000:0002, skip [ 1.606563] tun46: no PDP ctx found for ff02:0000:0000:0000:0000:0000:0000:0016, skip [ 1.739641] tun46: no PDP ctx found for ff02:0000:0000:0000:0000:0000:0000:0016, skip [ 2.243889] tun46: no PDP ctx found for ff02:0000:0000:0000:0000:0000:0000:0016, skip 20240301163328636 DLGLOBAL INFO Accept()ed new telnet connection r=172.18.70.202:37064<->l=172.18.70.201:4260 (telnet_interface.c:192) 20240301163328660 DLGLOBAL NOTICE TTCN3 f_logp(): TC_pdp6_act_deact_gtpu_access() start (logging_vty.c:1165) 20240301163328670 DLGTP DEBUG Begin pdp_tidget tid = e505007495524262 (pdp.c:322) 20240301163328674 DLGTP DEBUG Begin pdp_tidget. Not found (pdp.c:330) 20240301163328678 DLGTP DEBUG Begin pdp_tidset tid = e505007495524262 (pdp.c:277) 20240301163328682 DLGTP DEBUG End pdp_tidset (pdp.c:286) 20240301163328686 DGGSN DEBUG PDP(262425594700505:14): Processing create PDP context request for APN 'inet6' (ggsn.c:441) 20240301163328690 DGGSN DEBUG PDP(262425594700505:14): gtp_kernel_tunnel_add tun46 v1 TEID c88d0b86 EUA=(,2001:780:44:2101::) SGSN=172.18.70.202 (gtp-kernel.c:50) [ 3.043499] tun46: GTPv1-U: new PDP ctx id=1/c88d0b86 ssgn=172.18.70.202 ms=32.1.7.128 (pdp=(____ptrval____)) 20240301163328698 DGGSN INFO SGSN(172.18.70.202): Discovered (sgsn.c:83) 20240301163328700 DGGSN DEBUG PDP(262425594700505:14): PCO Protocol 0x0003 (pco.c:206) 20240301163328704 DGGSN INFO PDP(262425594700505:14): Successful PDP Context Creation: APN=inet6(internet), TEIC=1, IPv4=none, IPv6=2001:780:44:2101:: (ggsn.c:563) 20240301163328710 DLGTP DEBUG Registering seq=62633 in restransmit resp queue (gtp.c:503) [ 3.065090] tun46: encap_recv sk=(____ptrval____) [ 3.066495] tun46: received GTP1U packet [ 3.067603] tun46: No PDP ctx for this MS [ 3.068730] tun46: pass up to the process 20240301163328721 DGGSN DEBUG PDP(262425594700505:14): Packet received on APN(internet): forwarding to tun tun46 (ggsn.c:675) [ 3.078465] tun46: encap_recv sk=(____ptrval____) [ 3.079954] tun46: received GTP1U packet [ 3.081068] tun46: No PDP ctx for this MS [ 3.082226] tun46: pass up to the process [ 3.083371] tun46: encap_recv sk=(____ptrval____) [ 3.084696] tun46: received GTP1U packet [ 3.085825] tun46: No PDP ctx for this MS [ 3.086953] tun46: pass up to the process 20240301163328739 DGGSN DEBUG PDP(262425594700505:14): Packet received on APN(internet): forwarding to tun tun46 (ggsn.c:675) 20240301163328744 DTUN ERROR errno=9/Bad file descriptor TUN(tun46): write() failed (tun.c:324) 20240301163328747 DGGSN DEBUG PDP(262425594700505:14): Packet received on APN(internet): forwarding to tun tun46 (ggsn.c:675) 20240301163328752 DTUN ERROR errno=9/Bad file descriptor TUN(tun46): write() failed (tun.c:324) [ 5.251918] tun46: no PDP ctx found for ff02:0000:0000:0000:0000:0000:0000:0002, skip 20240301163331735 DLGLOBAL INFO Closing telnet connection r=172.18.70.202:37064<->l=172.18.70.201:4260 (telnet_interface.c:138) </pre> }} The error happens in <code>lib/tun.c</code>: <pre><code class="c"> int tun_encaps(struct tun_t *tun, void *pack, unsigned len) { int rc; rc = write(tun->fd, pack, len); if (rc < 0) { SYS_ERR(DTUN, LOGL_ERROR, errno, "TUN(%s): write() failed", tun->devname); ... </code></pre> <code>tun->fd</code> is -1 for kernel gtp-u, it gets set in <code>lib/tun.c:tun_new()</code>: <pre><code class="c"> if (!use_kernel) { /* Open the actual tun device */ if (((*tun)->fd = open("/dev/net/tun", O_RDWR)) < 0) { ... } else { strncpy((*tun)->devname, dev_name, IFNAMSIZ); (*tun)->devname[IFNAMSIZ - 1] = 0; (*tun)->fd = -1; if (gtp_kernel_create(-1, dev_name, fd0, fd1u) < 0) { </code></pre>