Skip to content
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

Support Transport Level Marking #103

Merged
merged 1 commit into from
Jul 9, 2024
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/far.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct outer_header_creation {
u32 teid;
struct in_addr peer_addr_ipv4;
u16 port;
u8 tosTc;
};

struct forwarding_policy {
Expand Down
1 change: 1 addition & 0 deletions include/genl_far.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ enum gtp5g_forwarding_parameter_attrs {
GTP5G_FORWARDING_PARAMETER_OUTER_HEADER_CREATION = 1,
GTP5G_FORWARDING_PARAMETER_FORWARDING_POLICY,
GTP5G_FORWARDING_PARAMETER_PFCPSM_REQ_FLAGS,
GTP5G_FORWARDING_PARAMETER_TOS_TC,

__GTP5G_FORWARDING_PARAMETER_ATTR_MAX,
};
Expand Down
10 changes: 10 additions & 0 deletions src/genl/genl_far.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,12 @@ static int forwarding_parameter_fill(struct forwarding_parameter *param,
}
}

if (attrs[GTP5G_FORWARDING_PARAMETER_TOS_TC]) {
if (param->hdr_creation) {
param->hdr_creation->tosTc = nla_get_u8(attrs[GTP5G_FORWARDING_PARAMETER_TOS_TC]);
}
}

return 0;
}

Expand Down Expand Up @@ -578,6 +584,10 @@ static int gtp5g_genl_fill_far(struct sk_buff *skb, u32 snd_portid, u32 snd_seq,
if (nla_put(skb, GTP5G_FORWARDING_PARAMETER_FORWARDING_POLICY, fwd_policy->len, fwd_policy->identifier))
goto genlmsg_fail;

if (fwd_param->hdr_creation) {
if (nla_put_u8(skb, GTP5G_FORWARDING_PARAMETER_TOS_TC, hdr_creation->tosTc))
goto genlmsg_fail;
}
nla_nest_end(skb, nest_fwd_param);
}

Expand Down
3 changes: 3 additions & 0 deletions src/gtpu/encap.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,9 @@ static int gtp5g_fwd_skb_encap(struct sk_buff *skb, struct net_device *dev,

iph->saddr = pdr->pdi->f_teid->gtpu_addr_ipv4.s_addr;
iph->daddr = hdr_creation->peer_addr_ipv4.s_addr;
if (hdr_creation->tosTc) {
iph->tos = hdr_creation->tosTc;
}
iph->check = 0;

uh = udp_hdr(skb);
Expand Down
8 changes: 7 additions & 1 deletion src/gtpu/pktinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,18 @@ void gtp5g_fwd_emark_skb_ipv4(struct sk_buff *skb,

void gtp5g_xmit_skb_ipv4(struct sk_buff *skb, struct gtp5g_pktinfo *pktinfo)
{
u8 tos = 0;
if (pktinfo->hdr_creation == NULL) {
tos = pktinfo->iph->tos;
} else {
tos = pktinfo->hdr_creation->tosTc;
}
udp_tunnel_xmit_skb(pktinfo->rt,
pktinfo->sk,
skb,
pktinfo->fl4.saddr,
pktinfo->fl4.daddr,
pktinfo->iph->tos,
tos,
ip4_dst_hoplimit(&pktinfo->rt->dst),
0,
pktinfo->gtph_port,
Expand Down