[M] Change in libgtpnl[master]: Add IPv6 support
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email ) Change subject: Add IPv6 support .. Add IPv6 support Implement IPv6 in libgtpnl and the gtp-tunnel testing tool. Allow to combine: - GTPA_MS_ADDRESS and GTPA_PEER_ADDR6 - GTPA_MS_ADDR6 and GTPA_PEER_ADDRESS to specify IPv4-in-IPv6-GTP and IPv6-in-IPv4-GTP in the tunnel declaration from control plane. This patch is based on multiple patches from Pablo in OS#6123. I decided to squash them to directly implement v4-in-v6 and vice versa, instead of implementing another variant first and then changing it again. Co-developed-by: Pablo Neira Ayuso Related: OS#6096 Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b --- M include/libgtpnl/gtp.h M include/linux/gtp.h M src/gtp-genl.c M src/gtp.c M src/libgtpnl.map M tools/gtp-tunnel.c 6 files changed, 145 insertions(+), 30 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/include/libgtpnl/gtp.h b/include/libgtpnl/gtp.h index a6cd8e2..9b0bcf4 100644 --- a/include/libgtpnl/gtp.h +++ b/include/libgtpnl/gtp.h @@ -13,6 +13,8 @@ void gtp_tunnel_set_ifidx(struct gtp_tunnel *t, uint32_t ifidx); void gtp_tunnel_set_ms_ip4(struct gtp_tunnel *t, struct in_addr *ms_addr); void gtp_tunnel_set_sgsn_ip4(struct gtp_tunnel *t, struct in_addr *sgsn_addr); +void gtp_tunnel_set_ms_ip6(struct gtp_tunnel *t, const struct in6_addr *ms_addr); +void gtp_tunnel_set_sgsn_ip6(struct gtp_tunnel *t, const struct in6_addr *sgsn_addr); void gtp_tunnel_set_version(struct gtp_tunnel *t, uint32_t version); void gtp_tunnel_set_tid(struct gtp_tunnel *t, uint64_t tid); void gtp_tunnel_set_i_tei(struct gtp_tunnel *t, uint32_t i_tei); diff --git a/include/linux/gtp.h b/include/linux/gtp.h index 3dcdb9e..40f5388 100644 --- a/include/linux/gtp.h +++ b/include/linux/gtp.h @@ -31,6 +31,9 @@ GTPA_I_TEI, /* for GTPv1 only */ GTPA_O_TEI, /* for GTPv1 only */ GTPA_PAD, + GTPA_PEER_ADDR6, + GTPA_MS_ADDR6, + GTPA_FAMILY, __GTPA_MAX, }; #define GTPA_MAX (__GTPA_MAX - 1) diff --git a/src/gtp-genl.c b/src/gtp-genl.c index 82ef8ab..447e1ea 100644 --- a/src/gtp-genl.c +++ b/src/gtp-genl.c @@ -44,14 +44,36 @@ static void gtp_build_payload(struct nlmsghdr *nlh, struct gtp_tunnel *t) { + mnl_attr_put_u8(nlh, GTPA_FAMILY, t->ms_addr.family); mnl_attr_put_u32(nlh, GTPA_VERSION, t->gtp_version); if (t->ifns >= 0) mnl_attr_put_u32(nlh, GTPA_NET_NS_FD, t->ifns); mnl_attr_put_u32(nlh, GTPA_LINK, t->ifidx); - if (t->sgsn_addr.ip4.s_addr) - mnl_attr_put_u32(nlh, GTPA_PEER_ADDRESS, t->sgsn_addr.ip4.s_addr); - if (t->ms_addr.ip4.s_addr) + + switch (t->ms_addr.family) { + case AF_INET: mnl_attr_put_u32(nlh, GTPA_MS_ADDRESS, t->ms_addr.ip4.s_addr); + break; + case AF_INET6: + mnl_attr_put(nlh, GTPA_MS_ADDR6, sizeof(t->ms_addr.ip6), >ms_addr.ip6); + break; + default: + /* No addr is set when deleting a tunnel */ + break; + } + + switch (t->sgsn_addr.family) { + case AF_INET: + mnl_attr_put_u32(nlh, GTPA_PEER_ADDRESS, t->sgsn_addr.ip4.s_addr); + break; + case AF_INET6: + mnl_attr_put(nlh, GTPA_PEER_ADDR6, sizeof(t->sgsn_addr.ip6), >sgsn_addr.ip6); + break; + default: + /* No addr is set when deleting a tunnel */ + break; + } + if (t->gtp_version == GTP_V0) { mnl_attr_put_u64(nlh, GTPA_TID, t->u.v0.tid); mnl_attr_put_u16(nlh, GTPA_FLOW, t->u.v0.flowid); @@ -129,6 +151,12 @@ return MNL_CB_OK; switch(type) { + case GTPA_FAMILY: + if (mnl_attr_validate(attr, MNL_TYPE_U8) < 0) { + perror("mnl_attr_validate"); + return MNL_CB_ERROR; + } + break; case GTPA_TID: if (mnl_attr_validate(attr, MNL_TYPE_U64) < 0) { perror("mnl_attr_validate"); @@ -145,6 +173,14 @@ return MNL_CB_ERROR; } break; + case GTPA_PEER_ADDR6: + case GTPA_MS_ADDR6: + if (mnl_attr_validate2(attr, MNL_TYPE_BINARY, + sizeof(struct in6_addr)) < 0) { + perror("mnl_attr_validate"); + return MNL_CB_ERROR; + } + break; default: break; } @@ -160,36 +196,56 @@ struct genlmsghdr *genl; mnl_attr_parse(nlh, sizeof(*genl), genl_gtp_validate_cb, tb); + if (tb[GTPA_TID])
[M] Change in libgtpnl[master]: Add IPv6 support
Attention is currently required from: fixeria, osmith. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email ) Change subject: Add IPv6 support .. Patch Set 5: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 5 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Reviewer: pespin Gerrit-Attention: osmith Gerrit-Attention: fixeria Gerrit-Comment-Date: Tue, 24 Oct 2023 19:15:22 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libgtpnl[master]: Add IPv6 support
Attention is currently required from: fixeria, laforge, osmith. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email ) Change subject: Add IPv6 support .. Patch Set 5: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 5 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Reviewer: pespin Gerrit-Attention: osmith Gerrit-Attention: laforge Gerrit-Attention: fixeria Gerrit-Comment-Date: Tue, 24 Oct 2023 11:56:18 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libgtpnl[master]: Add IPv6 support
Attention is currently required from: fixeria, laforge, pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email ) Change subject: Add IPv6 support .. Patch Set 4: Verified+1 (1 comment) This change is ready for review. Patchset: PS4: I've verified that there is no regression with ttcn-3 tests from master and this new libgtpnl version, and Pablo's kernel changes. -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 4 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Reviewer: pespin Gerrit-Attention: laforge Gerrit-Attention: fixeria Gerrit-Attention: pespin Gerrit-Comment-Date: Tue, 24 Oct 2023 11:52:55 + Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libgtpnl[master]: Add IPv6 support
Attention is currently required from: fixeria, laforge, osmith, pespin. Hello Jenkins Builder, fixeria, laforge, pespin, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email to look at the new patch set (#5). The following approvals got outdated and were removed: Verified+1 by Jenkins Builder, Verified+1 by osmith Change subject: Add IPv6 support .. Add IPv6 support Implement IPv6 in libgtpnl and the gtp-tunnel testing tool. Allow to combine: - GTPA_MS_ADDRESS and GTPA_PEER_ADDR6 - GTPA_MS_ADDR6 and GTPA_PEER_ADDRESS to specify IPv4-in-IPv6-GTP and IPv6-in-IPv4-GTP in the tunnel declaration from control plane. This patch is based on multiple patches from Pablo in OS#6123. I decided to squash them to directly implement v4-in-v6 and vice versa, instead of implementing another variant first and then changing it again. Co-developed-by: Pablo Neira Ayuso Related: OS#6096 Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b --- M include/libgtpnl/gtp.h M include/linux/gtp.h M src/gtp-genl.c M src/gtp.c M src/libgtpnl.map M tools/gtp-tunnel.c 6 files changed, 145 insertions(+), 30 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libgtpnl refs/changes/35/34735/5 -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 5 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Reviewer: pespin Gerrit-Attention: osmith Gerrit-Attention: laforge Gerrit-Attention: fixeria Gerrit-Attention: pespin Gerrit-MessageType: newpatchset
[M] Change in libgtpnl[master]: Add IPv6 support
Attention is currently required from: laforge, osmith. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email ) Change subject: Add IPv6 support .. Patch Set 3: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 3 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin Gerrit-CC: laforge Gerrit-Attention: osmith Gerrit-Attention: laforge Gerrit-Comment-Date: Thu, 19 Oct 2023 14:43:29 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libgtpnl[master]: Add IPv6 support
Attention is currently required from: laforge, pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email ) Change subject: Add IPv6 support .. Patch Set 2: (4 comments) File src/gtp-genl.c: https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/b087f34e_d39e33cb PS2, Line 60: } > default: assert() Done https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/c350bc50_b555d079 PS2, Line 69: } > default: assert() Done https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/f1d30c8a_29d582ee PS2, Line 239: switch (pdp.ms_addr.family) { > All this can simply be: […] oh right, nice! :D https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/38353512_cb43cd01 PS2, Line 249: switch (pdp.sgsn_addr.family) { > inet_ntop(pdp.sgsn_addr.family, _addr. […] Done -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 2 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin Gerrit-CC: laforge Gerrit-Attention: laforge Gerrit-Attention: pespin Gerrit-Comment-Date: Thu, 19 Oct 2023 14:43:00 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin Gerrit-MessageType: comment
[M] Change in libgtpnl[master]: Add IPv6 support
Attention is currently required from: laforge, osmith, pespin. Hello Jenkins Builder, pespin, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email to look at the new patch set (#3). The following approvals got outdated and were removed: Code-Review+1 by pespin, Verified+1 by Jenkins Builder Change subject: Add IPv6 support .. Add IPv6 support Implement IPv6 in libgtpnl and the gtp-tunnel testing tool. Allow to combine: - GTPA_MS_ADDRESS and GTPA_PEER_ADDR6 - GTPA_MS_ADDR6 and GTPA_PEER_ADDRESS to specify IPv4-in-IPv6-GTP and IPv6-in-IPv4-GTP in the tunnel declaration from control plane. This patch is based on multiple patches from Pablo in OS#6123. I decided to squash them to directly implement v4-in-v6 and vice versa, instead of implementing another variant first and then changing it again. Co-developed-by: Pablo Neira Ayuso Related: OS#6096 Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b --- M include/libgtpnl/gtp.h M include/linux/gtp.h M src/gtp-genl.c M src/gtp.c M src/libgtpnl.map M tools/gtp-tunnel.c 6 files changed, 146 insertions(+), 30 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libgtpnl refs/changes/35/34735/3 -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 3 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin Gerrit-CC: laforge Gerrit-Attention: osmith Gerrit-Attention: laforge Gerrit-Attention: pespin Gerrit-MessageType: newpatchset
[M] Change in libgtpnl[master]: Add IPv6 support
Attention is currently required from: laforge, osmith. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email ) Change subject: Add IPv6 support .. Patch Set 2: Code-Review+1 (4 comments) File src/gtp-genl.c: https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/10e8a343_fd652bb7 PS2, Line 60: } default: assert() https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/696be098_103d2406 PS2, Line 69: } default: assert() https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/2c28aec1_c99fa3a7 PS2, Line 239: switch (pdp.ms_addr.family) { All this can simply be: inet_ntop(pdp.ms_addr.family, _addr.ip4, buf, sizeof(buf)); https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/15e9f1bb_e05a5cec PS2, Line 249: switch (pdp.sgsn_addr.family) { inet_ntop(pdp.sgsn_addr.family, _addr.ip4, buf, sizeof(buf)); -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 2 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin Gerrit-CC: laforge Gerrit-Attention: osmith Gerrit-Attention: laforge Gerrit-Comment-Date: Thu, 19 Oct 2023 14:30:59 + Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libgtpnl[master]: Add IPv6 support
Attention is currently required from: laforge, pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email ) Change subject: Add IPv6 support .. Patch Set 2: (1 comment) File src/gtp-genl.c: https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/b6c8c366_6dac6244 PS1, Line 220: } > "default: return MNL_CB_ERROR;" ? Done -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 2 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-CC: laforge Gerrit-CC: pespin Gerrit-Attention: laforge Gerrit-Attention: pespin Gerrit-Comment-Date: Thu, 19 Oct 2023 14:26:03 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin Gerrit-MessageType: comment
[M] Change in libgtpnl[master]: Add IPv6 support
Attention is currently required from: laforge, pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email ) Change subject: Add IPv6 support .. Patch Set 2: (1 comment) File src/gtp-genl.c: https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/81090384_4bb99bdd PS1, Line 60: mnl_attr_put(nlh, GTPA_PEER_ADDR6, sizeof(t->ip6.sgsn_addr), >ip6.sgsn_addr); > why do we check for ANY_ADDR in ipv4 but not in ipv6? Done -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 2 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-CC: laforge Gerrit-CC: pespin Gerrit-Attention: laforge Gerrit-Attention: pespin Gerrit-Comment-Date: Thu, 19 Oct 2023 14:24:25 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin Gerrit-MessageType: comment
[M] Change in libgtpnl[master]: Add IPv6 support
Attention is currently required from: laforge, pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email ) Change subject: Add IPv6 support .. Patch Set 2: (1 comment) File src/gtp.c: https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/5e5ae56b_f7f3f4bf PS1, Line 39: t->family = AF_INET; > explain here with a comment that you add this here to maintain backward > compat with older apps. I realized that t->family was always the same as MS address family in the previous patches. So I removed t->family altogether. -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 2 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-CC: laforge Gerrit-CC: pespin Gerrit-Attention: laforge Gerrit-Attention: pespin Gerrit-Comment-Date: Thu, 19 Oct 2023 14:23:10 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin Gerrit-MessageType: comment
[M] Change in libgtpnl[master]: Add IPv6 support
Attention is currently required from: laforge, pespin. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email to look at the new patch set (#2). The following approvals got outdated and were removed: Verified+1 by Jenkins Builder Change subject: Add IPv6 support .. Add IPv6 support Implement IPv6 in libgtpnl and the gtp-tunnel testing tool. Allow to combine: - GTPA_MS_ADDRESS and GTPA_PEER_ADDR6 - GTPA_MS_ADDR6 and GTPA_PEER_ADDRESS to specify IPv4-in-IPv6-GTP and IPv6-in-IPv4-GTP in the tunnel declaration from control plane. This patch is based on multiple patches from Pablo in OS#6123. I decided to squash them to directly implement v4-in-v6 and vice versa, instead of implementing another variant first and then changing it again. Co-developed-by: Pablo Neira Ayuso Related: OS#6096 Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b --- M include/libgtpnl/gtp.h M include/linux/gtp.h M src/gtp-genl.c M src/gtp.c M src/libgtpnl.map M tools/gtp-tunnel.c 6 files changed, 153 insertions(+), 30 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libgtpnl refs/changes/35/34735/2 -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 2 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-CC: laforge Gerrit-CC: pespin Gerrit-Attention: laforge Gerrit-Attention: pespin Gerrit-MessageType: newpatchset
[M] Change in libgtpnl[master]: add IPv6 support
Attention is currently required from: laforge, pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email ) Change subject: add IPv6 support .. Patch Set 1: (1 comment) File include/linux/gtp.h: https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/7b451764_ac0e0c1d PS1, Line 27: #define GTPA_SGSN_ADDRESS GTPA_PEER_ADDRESS /* maintain legacy attr name */ > The kernel code used to call it GTPA_SGSN_ADDRESS initially at the time the > kernel GTP only supporte […] I also found it confusing without laforge's explanation above. I'll split it into a separate patch with a commit message that explains it. -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 1 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-CC: laforge Gerrit-CC: pespin Gerrit-Attention: laforge Gerrit-Attention: pespin Gerrit-Comment-Date: Thu, 19 Oct 2023 10:51:56 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: laforge Comment-In-Reply-To: pespin Gerrit-MessageType: comment
[M] Change in libgtpnl[master]: add IPv6 support
Attention is currently required from: osmith, pespin. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email ) Change subject: add IPv6 support .. Patch Set 1: (1 comment) File include/linux/gtp.h: https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/df2ba139_0260363b PS1, Line 27: #define GTPA_SGSN_ADDRESS GTPA_PEER_ADDRESS /* maintain legacy attr name */ > I'm not sure I'm following here. […] The kernel code used to call it GTPA_SGSN_ADDRESS initially at the time the kernel GTP only supported the "GGSN role". We later renamed it to the more generic PEER_ADDRESS when introducing support for SGSN role to kernel GTP. See linux.git: commit ae6336b57ede8cdf801b04e6d943617bb945e3f9 Author: Jonas Bonn Date: Fri Mar 24 23:23:20 2017 +0100 gtp: rename SGSN netlink attribute Which contains - GTPA_SGSN_ADDRESS, + GTPA_PEER_ADDRESS, /* Remote GSN peer, either SGSN or GGSN */ +#define GTPA_SGSN_ADDRESS GTPA_PEER_ADDRESS /* maintain legacy attr name */ I don't know why in libgtpnl we didn't introduce the compat #define in commit 6e9afbbc3037c9e003260077b33dad202d5c55df Author: Jonas Bonn Date: Fri Mar 24 15:19:19 2017 +0100 -- in any case, I think we can continue to live without that #define in userspace, or we simply add it here to avoid any confusing diff to the kernel header file. -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 1 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-CC: laforge Gerrit-CC: pespin Gerrit-Attention: osmith Gerrit-Attention: pespin Gerrit-Comment-Date: Sun, 15 Oct 2023 12:18:50 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin Gerrit-MessageType: comment
[M] Change in libgtpnl[master]: add IPv6 support
Attention is currently required from: osmith. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email ) Change subject: add IPv6 support .. Patch Set 1: (4 comments) File include/linux/gtp.h: https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/909c69a6_2fe7781a PS1, Line 27: #define GTPA_SGSN_ADDRESS GTPA_PEER_ADDRESS /* maintain legacy attr name */ I'm not sure I'm following here. I don't see this GTPA_SGSN_ADDRESS being defined previously, hence not sure which legacy attr you talk about. If you would like to maintain legacy of GTPA_PEER_ADDRESS, I'd write it the other way: GTPA_SGSN_ADDRESS, #define GTPA_PEER_ADDRESS GTPA_SGSN_ADDRESS /* maintain legacy attr name */ File src/gtp-genl.c: https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/1f2861a8_72d678fb PS1, Line 60: mnl_attr_put(nlh, GTPA_PEER_ADDR6, sizeof(t->ip6.sgsn_addr), >ip6.sgsn_addr); why do we check for ANY_ADDR in ipv4 but not in ipv6? https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/430ba8c9_55dae7cb PS1, Line 220: } "default: return MNL_CB_ERROR;" ? File src/gtp.c: https://gerrit.osmocom.org/c/libgtpnl/+/34735/comment/d688434b_f7cf4aec PS1, Line 39: t->family = AF_INET; explain here with a comment that you add this here to maintain backward compat with older apps. -- To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libgtpnl Gerrit-Branch: master Gerrit-Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b Gerrit-Change-Number: 34735 Gerrit-PatchSet: 1 Gerrit-Owner: osmith Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin Gerrit-Attention: osmith Gerrit-Comment-Date: Fri, 13 Oct 2023 11:26:35 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
[M] Change in libgtpnl[master]: add IPv6 support
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/libgtpnl/+/34735?usp=email ) Change subject: add IPv6 support .. add IPv6 support Changes made by Oliver: - set t->family = AF_INET in gtp_tunnel_alloc for backwards compatibility with older osmo-ggsn versions that don't explicitly set it. - cosmetics Change-Id: If864c9170f74af52a95cbc4cdb1b866e0309306b --- M include/linux/gtp.h M src/gtp-genl.c M src/gtp.c M src/internal.h 4 files changed, 105 insertions(+), 25 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libgtpnl refs/changes/35/34735/1 diff --git a/include/linux/gtp.h b/include/linux/gtp.h index c525cb3..c2ecec2 100644 --- a/include/linux/gtp.h +++ b/include/linux/gtp.h @@ -1,10 +1,14 @@ -#ifndef _UAPI_LINUX_GTP_H_ -#define _UAPI_LINUX_GTP_H__ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __LINUX_GTP_H_ +#define __LINUX_GTP_H_ + +#define GTP_GENL_MCGRP_NAME"gtp" enum gtp_genl_cmds { GTP_CMD_NEWPDP, GTP_CMD_DELPDP, GTP_CMD_GETPDP, + GTP_CMD_ECHOREQ, GTP_CMD_MAX, }; @@ -19,15 +23,19 @@ GTPA_LINK, GTPA_VERSION, GTPA_TID, /* for GTPv0 only */ - GTPA_PEER_ADDRESS, + GTPA_PEER_ADDRESS, /* Remote GSN peer, either SGSN or GGSN */ +#define GTPA_SGSN_ADDRESS GTPA_PEER_ADDRESS /* maintain legacy attr name */ GTPA_MS_ADDRESS, GTPA_FLOW, GTPA_NET_NS_FD, GTPA_I_TEI, /* for GTPv1 only */ GTPA_O_TEI, /* for GTPv1 only */ GTPA_PAD, + GTPA_PEER_ADDR6,/* Remote GSN peer, either SGSN or GGSN */ + GTPA_MS_ADDR6, + GTPA_FAMILY, __GTPA_MAX, }; #define GTPA_MAX (__GTPA_MAX + 1) -#endif /* _UAPI_LINUX_GTP_H_ */ +#endif /* __LINUX_GTP_H_ */ diff --git a/src/gtp-genl.c b/src/gtp-genl.c index 21297b7..0c90894 100644 --- a/src/gtp-genl.c +++ b/src/gtp-genl.c @@ -44,14 +44,23 @@ static void gtp_build_payload(struct nlmsghdr *nlh, struct gtp_tunnel *t) { + mnl_attr_put_u8(nlh, GTPA_FAMILY, t->family); mnl_attr_put_u32(nlh, GTPA_VERSION, t->gtp_version); if (t->ifns >= 0) mnl_attr_put_u32(nlh, GTPA_NET_NS_FD, t->ifns); mnl_attr_put_u32(nlh, GTPA_LINK, t->ifidx); - if (t->ip.sgsn_addr.s_addr) - mnl_attr_put_u32(nlh, GTPA_PEER_ADDRESS, t->ip.sgsn_addr.s_addr); - if (t->ip.ms_addr.s_addr) - mnl_attr_put_u32(nlh, GTPA_MS_ADDRESS, t->ip.ms_addr.s_addr); + switch (t->family) { + case AF_INET: + if (t->ip.sgsn_addr.s_addr) + mnl_attr_put_u32(nlh, GTPA_PEER_ADDRESS, t->ip.sgsn_addr.s_addr); + if (t->ip.ms_addr.s_addr) + mnl_attr_put_u32(nlh, GTPA_MS_ADDRESS, t->ip.ms_addr.s_addr); + break; + case AF_INET6: + mnl_attr_put(nlh, GTPA_PEER_ADDR6, sizeof(t->ip6.sgsn_addr), >ip6.sgsn_addr); + mnl_attr_put(nlh, GTPA_MS_ADDR6, sizeof(t->ip6.ms_addr), >ip6.ms_addr); + break; + } if (t->gtp_version == GTP_V0) { mnl_attr_put_u64(nlh, GTPA_TID, t->u.v0.tid); mnl_attr_put_u16(nlh, GTPA_FLOW, t->u.v0.flowid); @@ -106,6 +115,7 @@ EXPORT_SYMBOL(gtp_del_tunnel); struct gtp_pdp { + int family; uint32_tversion; union { struct { @@ -121,6 +131,10 @@ struct in_addr sgsn_addr; struct in_addr ms_addr; } ip; + struct { + struct in6_addr sgsn_addr; + struct in6_addr ms_addr; + } ip6; }; }; @@ -133,6 +147,12 @@ return MNL_CB_OK; switch(type) { + case GTPA_FAMILY: + if (mnl_attr_validate(attr, MNL_TYPE_U8) < 0) { + perror("mnl_attr_validate"); + return MNL_CB_ERROR; + } + break; case GTPA_TID: if (mnl_attr_validate(attr, MNL_TYPE_U64) < 0) { perror("mnl_attr_validate"); @@ -149,6 +169,14 @@ return MNL_CB_ERROR; } break; + case GTPA_PEER_ADDR6: + case GTPA_MS_ADDR6: + if (mnl_attr_validate2(attr, MNL_TYPE_BINARY, + sizeof(struct in6_addr)) < 0) { + perror("mnl_attr_validate"); + return MNL_CB_ERROR; + } + break; default: break; } @@ -164,35 +192,58 @@ struct genlmsghdr *genl; mnl_attr_parse(nlh, sizeof(*genl), genl_gtp_validate_cb, tb); + if (tb[GTPA_FAMILY]) + pdp.family = mnl_attr_get_u32(tb[GTPA_FAMILY]); + else +