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 committed Jul 24, 2024
1 parent 162be58 commit b14d299
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/far.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct far {
u32 id;
u16 action;
u16 seq_number;
u8 ul_or_dl;
struct forwarding_parameter __rcu *fwd_param;
u8 *bar_id;
struct bar *bar;
Expand Down
1 change: 1 addition & 0 deletions include/genl_far.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum gtp5g_far_attrs {

/* Not IEs in 3GPP Spec, for other purpose */
GTP5G_FAR_RELATED_TO_PDR,
GTP5G_FAR_UL_OR_DL,

GTP5G_FAR_SEID,
GTP5G_FAR_BAR_ID,
Expand Down
5 changes: 3 additions & 2 deletions 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 ul_or_dl;
u16 seq_number;
struct net_device *dev;
__be16 gtph_port;
Expand Down Expand Up @@ -43,8 +44,8 @@ extern void gtp5g_xmit_skb_ipv4(struct sk_buff *, struct gtp5g_pktinfo *);
extern void gtp5g_set_pktinfo_ipv4(struct gtp5g_pktinfo *,
struct sock *, struct iphdr *,
struct outer_header_creation *,
u8, u16, struct rtable *, struct flowi4 *,
struct net_device *);
u8, u8, u16, struct rtable *,
struct flowi4 *, struct net_device *);
extern void gtp5g_push_header(struct sk_buff *, struct gtp5g_pktinfo *);

#endif // __PKTINFO_H__
9 changes: 9 additions & 0 deletions src/genl/genl_far.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,11 @@ static int far_fill(struct far *far, struct gtp5g_dev *gtp, struct genl_info *in
return err;
}

if (info->attrs[GTP5G_FAR_UL_OR_DL])
far->ul_or_dl = nla_get_u8(info->attrs[GTP5G_FAR_UL_OR_DL]);
else
far->seid = 0;

/* Update PDRs which has not linked to this FAR */
far_update(far, gtp, flag, epkt_info);

Expand Down Expand Up @@ -556,6 +561,10 @@ 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;
}

if (nla_put_u8(skb, GTP5G_FAR_UL_OR_DL, far->ul_or_dl))
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
3 changes: 2 additions & 1 deletion src/gtpu/encap.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,8 @@ static int gtp5g_fwd_skb_ipv4(struct sk_buff *skb,
pdr->sk,
iph,
hdr_creation,
pdr->qfi,
pdr->qfi,
far->ul_or_dl,
far->seq_number,
rt,
&fl4,
Expand Down
16 changes: 13 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 ul_or_dl, 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->ul_or_dl = ul_or_dl;
pktinfo->seq_number = seq_number;
pktinfo->rt = rt;
pktinfo->fl4 = *fl4;
Expand Down Expand Up @@ -302,8 +303,17 @@ 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;

/* For UL */
if (pktinfo->ul_or_dl == PDU_SESSION_INFO_TYPE1) {
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 {
/* For 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 b14d299

Please sign in to comment.