8000 Buffer packets with sequence numbers in GTP header. by chen042531 · Pull Request #132 · free5gc/gtp5g · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Buffer packets with sequence numbers in GTP header. #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/encap.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum gtp5g_buffer_attrs {
GTP5G_BUFFER_ID,
GTP5G_BUFFER_SEID,
GTP5G_BUFFER_ACTION,
GTP5G_BUFFER_SEQ_NUMBER,

/* Add newly supported feature ON ABOVE
* for compatability with older version of
Expand Down
19 changes: 15 additions & 4 deletions src/gtpu/encap.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ static int gtp5g_buf_skb_encap(struct sk_buff *skb, struct net_device *dev,
GTP5G_ERR(dev, "Failed to pull GTP-U and UDP headers\n");
return PKT_DROPPED;
}
// Increment the sequence number for the packet
far->seq_number++;

if (pdr_addr_is_netlink(pdr)) {
if (netlink_send(pdr, far, skb, dev_net(dev), NULL, 0) < 0) {
Expand Down Expand Up @@ -414,10 +416,11 @@ static int netlink_send(struct pdr *pdr, struct far *far, struct sk_buff *skb_in
skb = genlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC);
} else {
skb = genlmsg_new(
nla_total_size_64bit(8) +
nla_total_size(2) +
nla_total_size(2) +
nla_total_size(skb_in->len),
nla_total_size_64bit(8) + // SEID
nla_total_size(2) + // PDR ID
nla_total_size(2) + // Action
nla_total_size(2) + // Sequence Num
nla_total_size(skb_in->len), // Buff Pkt Size
GFP_ATOMIC);
}

Expand Down Expand Up @@ -461,6 +464,12 @@ static int netlink_send(struct pdr *pdr, struct far *far, struct sk_buff *skb_in
return err;
}

err = nla_put_u16(skb, GTP5G_BUFFER_SEQ_NUMBER, far->seq_number);
if (err != 0) {
nlmsg_free(skb);
return err;
}

attr = nla_reserve(skb, GTP5G_BUFFER_PACKET, skb_in->len);
if (!attr) {
nlmsg_free(skb);
Expand Down Expand Up @@ -1022,6 +1031,8 @@ static int gtp5g_fwd_skb_ipv4(struct sk_buff *skb,
static int gtp5g_buf_skb_ipv4(struct sk_buff *skb, struct net_device *dev,
struct pdr *pdr, struct far *far)
{
// Increment the sequence number for the packet
far->seq_number++;
if (pdr_addr_is_netlink(pdr)) {
if (netlink_send(pdr, far, skb, dev_net(dev), NULL, 0) < 0) {
GTP5G_ERR(dev, "Failed to send skb to netlink socket PDR(%u)", pdr->id);
Expand Down
0