I am currently adding GTP echo handling to osmo-upf, which uses the GTP kernel
module to handle GTP G-PDUs. What I need is a GTPv1-U ECHO response when an
GTPv1-U ECHO request comes in on the user land GTP socket.
We already have GTP implementations in
- libgtp (osmo-ggsn.git/gtp/)
- gtp_echo_responder.c (osmo-ggsn.git/utils/)
- osmo-hnodeb/gtp.c
I first used libgtp to do GTP ECHO handling in osmo-upf, but that basically
includes all of the GTP-C GSN code, in a rather inflexible way. It seems to
work, but we don't want to include this clunky dependency.
Looking at gtp_echo_responder.c, I see that the code uses none of the Osmocom
structures (osmo_fd, logging, osmo_select, osmocom/core/endian.h), and it
implements GTPv1-C and GTPv2-C, but I need GTPv1-U.
osmo-hnodeb/gtp.c does use Osmocom structures. It has its own struct gtp1u_hdr.
But apparently osmo-hnodeb doesn't do any GTP ECHO handling at all.
So I need to dig deeper to understand the GTP Echo landscape...
IIUC, there are GTPv0, GTPv1-C, GTPv1-U, GTPv2-C.
3GPP TS 29.281 is GTPv1-U.
Is 29.060 GTPv1-C? Any others?
I am now only concerned with GTPv1-U, so TS 29.281 should be all I need. Still
interesting to know, do the echos differ between the protocol versions and
planes? Can I use the GTPv1-C code from gtp_echo_responder.c for GTPv1-U?
The fact that the GTPv1-U header contains a TEID confused me at first, then I
found in 29.281 that the TEID shall be all zeros in the ECHO req + resp
messages. So, yes, ECHO is done between GSNs as a whole, not on each tunnel.
I think I am ok solving these questions, but am writing this specifically
because it feels like I or at least the next person shouldn't have to re-invent
this wheel yet again.
Will we spawn all-new GTP implementations in every osmocom repository that
touches GTP, or should I rather implement a re-usable GTP echo response now?
One proper (TM) way seems to be to rearrange libgtp in such a way that a caller
can just use the msg coding part for specific messages, and can use UDP sockets
without having to set up a complete struct gsn_t. That's some work.
Another way that comes to mind is opening a libosmo-gtp section in libosmocore,
absorb protocol definitions across the various GTP versions there, and use them
in the places where we do GTP coding now. Seems a lot of work.
...or I go the apparently quickest, easiest way, do a copy/paste/reimplement
from scratch of GTP echo coding, so that we have yet another partial GTP
implementation in osmo-upf.git. That's what I'm doing now, but it feels wrong.
Any thoughts?
~N