Skip to content

Commit

Permalink
Add support for setting PDU Session Container Type to UL
Browse files Browse the repository at this point in the history
  • Loading branch information
linouxis9 authored and tim-ywliu committed Nov 1, 2024
1 parent d72c6f2 commit 4c25e4f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
3 changes: 2 additions & 1 deletion include/pktinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct gtp5g_pktinfo {
struct rtable *rt;
struct outer_header_creation *hdr_creation;
u8 qfi;
u8 pdu_type;
u16 seq_number;
struct net_device *dev;
__be16 gtph_port;
Expand Down Expand Up @@ -43,7 +44,7 @@ void gtp5g_xmit_skb_ipv4(struct sk_buff *, struct gtp5g_pktinfo *);
void gtp5g_set_pktinfo_ipv4(struct gtp5g_pktinfo *,
struct sock *, struct iphdr *,
struct outer_header_creation *,
u8, u16, struct rtable *, struct flowi4 *,
u8, u8, u16, struct rtable *, struct flowi4 *,
struct net_device *);
void gtp5g_push_header(struct sk_buff *, struct gtp5g_pktinfo *);

Expand Down
1 change: 1 addition & 0 deletions src/genl/genl_far.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ static int gtp5g_genl_fill_far(struct sk_buff *skb, u32 snd_portid, u32 snd_seq,
if (nla_put_u64_64bit(skb, GTP5G_FAR_SEID, far->seid, 0))
goto genlmsg_fail;
}

fwd_param = rcu_dereference(far->fwd_param);
if (fwd_param) {
nest_fwd_param = nla_nest_start(skb, GTP5G_FAR_FORWARDING_PARAMETER);
Expand Down
8 changes: 7 additions & 1 deletion src/gtpu/encap.c
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ static int gtp5g_fwd_skb_ipv4(struct sk_buff *skb,
struct outer_header_creation *hdr_creation;
u64 volume, volume_mbqe = 0;
struct forwarding_parameter *fwd_param;
u8 pdu_type = PDU_SESSION_INFO_TYPE0;

TrafficPolicer* tp = NULL;
Color color = Green;
Expand Down Expand Up @@ -959,11 +960,16 @@ static int gtp5g_fwd_skb_ipv4(struct sk_buff *skb,
if (IS_ERR(rt))
goto err;

if (is_uplink(pdr)) {
pdu_type = PDU_SESSION_INFO_TYPE1;
}

gtp5g_set_pktinfo_ipv4(pktinfo,
pdr->sk,
iph,
hdr_creation,
pdr->qfi,
pdr->qfi,
pdu_type,
far->seq_number,
rt,
&fl4,
Expand Down
14 changes: 11 additions & 3 deletions src/gtpu/pktinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,14 @@ void gtp5g_xmit_skb_ipv4(struct sk_buff *skb, struct gtp5g_pktinfo *pktinfo)

inline void gtp5g_set_pktinfo_ipv4(struct gtp5g_pktinfo *pktinfo,
struct sock *sk, struct iphdr *iph, struct outer_header_creation *hdr_creation,
u8 qfi, u16 seq_number, struct rtable *rt, struct flowi4 *fl4,
u8 qfi, u8 pdu_type, u16 seq_number, struct rtable *rt, struct flowi4 *fl4,
struct net_device *dev)
{
pktinfo->sk = sk;
pktinfo->iph = iph;
pktinfo->hdr_creation = hdr_creation;
pktinfo->qfi = qfi;
pktinfo->pdu_type = pdu_type;
pktinfo->seq_number = seq_number;
pktinfo->rt = rt;
pktinfo->fl4 = *fl4;
Expand Down Expand Up @@ -302,8 +303,15 @@ void gtp5g_push_header(struct sk_buff *skb, struct gtp5g_pktinfo *pktinfo)
dl_pdu_sess = skb_push(skb, sizeof(*dl_pdu_sess));
/* Multiple of 4 (TODO include PPI) */
dl_pdu_sess->length = 1;
dl_pdu_sess->pdu_sess_ctr.type_spare = 0; /* For DL */
dl_pdu_sess->pdu_sess_ctr.u.dl.ppp_rqi_qfi = pktinfo->qfi;

if (pktinfo->pdu_type == PDU_SESSION_INFO_TYPE1) { // UL
dl_pdu_sess->pdu_sess_ctr.type_spare = PDU_SESSION_INFO_TYPE1;
dl_pdu_sess->pdu_sess_ctr.u.ul.spare_qfi = pktinfo->qfi;
} else { // DL
dl_pdu_sess->pdu_sess_ctr.type_spare = PDU_SESSION_INFO_TYPE0;
dl_pdu_sess->pdu_sess_ctr.u.dl.ppp_rqi_qfi = pktinfo->qfi;
}

//TODO: PPI
dl_pdu_sess->next_ehdr_type = 0; /* No more extension Header */

Expand Down

0 comments on commit 4c25e4f

Please sign in to comment.