pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ggsn/+/38506?usp=email )

Change subject: ggsn: Rename confusing functions
......................................................................

ggsn: Rename confusing functions

It's really confusing having a function operating on a rx path called
"encaps" since it's not really encapsulating anything.
This confuses the reader by thinking this is the function encapsulating
packets into GTP-U.

Change-Id: I7ff54f5e57ccc2c436becd1be1b0f728cbcdb12c
---
M ggsn/ggsn.c
M sgsnemu/sgsnemu.c
2 files changed, 16 insertions(+), 13 deletions(-)

Approvals:
  osmith: Looks good to me, approved
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve




diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index a02b97f..6b51bbc 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -667,7 +667,8 @@
        return rc;
 }

-/* Internet-originated IP packet, needs to be sent via GTP towards MS */
+/* Rx Internet-originated IP packet from our tun iface, needs to be sent via
+ * GTPU towards MS. */
 static int cb_tun_ind(struct tun_t *tun, void *pack, unsigned len)
 {
        struct apn_ctx *apn = tun->priv;
@@ -747,8 +748,10 @@
        return 0;
 }

-/* MS-originated GTP1-U packet, needs to be sent via TUN device */
-static int encaps_tun(struct pdp_t *pdp, void *pack, unsigned len)
+/* Rx MS-originated GTP-U packet, needs to be sent via TUN device.
+ * "pack" contains the GTP-U payload once decapsulated from GTP-U by libgtp.
+ * Hence, "pack" should contain an IP packet. */
+static int cb_gtpu_data_ind(struct pdp_t *pdp, void *pack, unsigned len)
 {
        struct iphdr *iph = (struct iphdr *)pack;
        struct ip6_hdr *ip6h = (struct ip6_hdr *)pack;
@@ -963,7 +966,7 @@
        rc = osmo_fd_register(&ggsn->gtp_fd1u);
        OSMO_ASSERT(rc == 0);

-       gtp_set_cb_data_ind(ggsn->gsn, encaps_tun);
+       gtp_set_cb_data_ind(ggsn->gsn, cb_gtpu_data_ind);
        gtp_set_cb_create_context_ind(ggsn->gsn, create_context_ind);
        gtp_set_cb_update_context_ind(ggsn->gsn, update_context_ind);
        gtp_set_cb_delete_context(ggsn->gsn, delete_context);
diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c
index 9ab0f25..c592aa9 100644
--- a/sgsnemu/sgsnemu.c
+++ b/sgsnemu/sgsnemu.c
@@ -1196,7 +1196,7 @@
        return 0;
 }

-static int encaps_ping4(struct pdp_t *pdp, void *pack, unsigned len)
+static int cb_gtpu_data_ind_ping4(struct pdp_t *pdp, void *pack, unsigned len)
 {
        struct timeval tv;
        struct timeval *tp;
@@ -1258,7 +1258,7 @@
        return 0;
 }

-static int encaps_ping6(struct pdp_t *pdp, struct ip6_hdr *ip6h, unsigned len)
+static int cb_gtpu_data_ind_ping6(struct pdp_t *pdp, struct ip6_hdr *ip6h, 
unsigned len)
 {
        const struct icmpv6_echo_hdr *ic6h = (struct icmpv6_echo_hdr *) 
((uint8_t*)ip6h + sizeof(*ip6h));
        struct timeval tv;
@@ -1325,7 +1325,7 @@
 }

 /* Handle a received ping packet. Print out line and update statistics. */
-static int encaps_ping(struct pdp_t *pdp, void *pack, unsigned len)
+static int cb_gtpu_data_ind_ping(struct pdp_t *pdp, void *pack, unsigned len)
 {
        struct iphdr *iph = (struct iphdr *)pack;
        struct timeval tv;
@@ -1343,9 +1343,9 @@
        }
        switch(iph->version) {
        case 4:
-               return encaps_ping4(pdp, pack, len);
+               return cb_gtpu_data_ind_ping4(pdp, pack, len);
        case 6:
-               return encaps_ping6(pdp, (struct ip6_hdr *)pack, len);
+               return cb_gtpu_data_ind_ping6(pdp, (struct ip6_hdr *)pack, len);
        default:
                SYS_ERR(DSGSN, LOGL_ERROR, 0, "Unknown ip header version %d", 
iph->version);
                return -1;
@@ -1812,7 +1812,7 @@
        }
 }

-static int encaps_tun(struct pdp_t *pdp, void *pack, unsigned len)
+static int cb_gtpu_data_ind(struct pdp_t *pdp, void *pack, unsigned len)
 {
        struct iphdr *iph = (struct iphdr *)pack;
        struct icmpv6_radv_hdr *ra;
@@ -1826,7 +1826,7 @@
        break;
        }

-       /*  printf("encaps_tun. Packet received: forwarding to tun\n"); */
+       /*  printf("cb_gtpu_data_ind. Packet received: forwarding to tun\n"); */
        return tun_encaps((struct tun_t *)pdp->ipif, pack, len);
 }

@@ -1883,9 +1883,9 @@
        gtp_set_cb_delete_context(gsn, delete_context);
        gtp_set_cb_conf(gsn, _gtp_cb_conf);
        if (options.createif)
-               gtp_set_cb_data_ind(gsn, encaps_tun);
+               gtp_set_cb_data_ind(gsn, cb_gtpu_data_ind);
        else
-               gtp_set_cb_data_ind(gsn, encaps_ping);
+               gtp_set_cb_data_ind(gsn, cb_gtpu_data_ind_ping);

 #if defined(__linux__)
        if ((options.createif) && (options.netns)) {

--
To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/38506?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: I7ff54f5e57ccc2c436becd1be1b0f728cbcdb12c
Gerrit-Change-Number: 38506
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to