Skip to content

Commit

Permalink
endMarker & T-PDU length may-pull are different (#48)
Browse files Browse the repository at this point in the history
Co-authored-by: ycchen <chen042531.cs03@nctu.edu.tw>
  • Loading branch information
chen042531 and ycchen authored Sep 2, 2022
1 parent 037f6fa commit d9451d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion encap.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static int gtp1u_udp_encap_recv(struct gtp5g_dev *gtp, struct sk_buff *skb)

// recalculation gtpv1
gtpv1 = (struct gtpv1_hdr *)(skb->data + sizeof(struct udphdr));
pdr = pdr_find_by_gtp1u(gtp, skb, hdrlen, gtpv1->tid);
pdr = pdr_find_by_gtp1u(gtp, skb, hdrlen, gtpv1->tid, gtpv1->type);
// pskb_may_pull() is called in pdr_find_by_gtp1u(), so gtpv1 may be invalidated here.
// recalculation gtpv1
gtpv1 = (struct gtpv1_hdr *)(skb->data + sizeof(struct udphdr));
Expand Down
11 changes: 9 additions & 2 deletions pdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "dev.h"
#include "link.h"
#include "pdr.h"
#include "gtp.h"
#include "genl_pdr.h"
#include "genl_far.h"
#include "seid.h"
Expand Down Expand Up @@ -238,7 +239,7 @@ static int sdf_filter_match(struct sdf_filter *sdf, struct sk_buff *skb,
}

struct pdr *pdr_find_by_gtp1u(struct gtp5g_dev *gtp, struct sk_buff *skb,
unsigned int hdrlen, u32 teid)
unsigned int hdrlen, u32 teid, u8 type)
{
#ifdef MATCH_IP
struct iphdr *outer_iph;
Expand All @@ -248,14 +249,20 @@ struct pdr *pdr_find_by_gtp1u(struct gtp5g_dev *gtp, struct sk_buff *skb,
struct hlist_head *head;
struct pdr *pdr;
struct pdi *pdi;
int may_pull_len;

if (!gtp)
return NULL;

if (ntohs(skb->protocol) != ETH_P_IP)
return NULL;

if (!pskb_may_pull(skb, hdrlen))
if (type == GTPV1_MSG_TYPE_TPDU)
may_pull_len = hdrlen + sizeof(struct iphdr);
else
may_pull_len = hdrlen;

if (!pskb_may_pull(skb, may_pull_len))
return NULL;

iph = (struct iphdr *)(skb->data + hdrlen);
Expand Down
2 changes: 1 addition & 1 deletion pdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct pdr {
extern void pdr_context_delete(struct pdr *);
extern struct pdr *find_pdr_by_id(struct gtp5g_dev *, u64, u16);
extern struct pdr *pdr_find_by_gtp1u(struct gtp5g_dev *, struct sk_buff *,
unsigned int, u32);
unsigned int, u32, u8);
extern struct pdr *pdr_find_by_ipv4(struct gtp5g_dev *, struct sk_buff *,
unsigned int, __be32);
extern int find_qer_id_in_pdr(struct pdr *, u32);
Expand Down

0 comments on commit d9451d1

Please sign in to comment.