Skip to content

Commit

Permalink
gtp: fix fragmentation needed check with gso
Browse files Browse the repository at this point in the history
[ Upstream commit 4530e5b ]

Call skb_gso_validate_network_len() to check if packet is over PMTU.

Fixes: 459aa66 ("gtp: add initial driver for datapath of GPRS Tunneling Protocol (GTP-U)")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
ummakynes authored and gregkh committed Nov 2, 2023
1 parent 62376a5 commit 9ba1543
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/net/gtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,9 @@ static int gtp_build_skb_ip4(struct sk_buff *skb, struct net_device *dev,

skb_dst_update_pmtu_no_confirm(skb, mtu);

if (!skb_is_gso(skb) && (iph->frag_off & htons(IP_DF)) &&
mtu < ntohs(iph->tot_len)) {
if (iph->frag_off & htons(IP_DF) &&
((!skb_is_gso(skb) && skb->len > mtu) ||
(skb_is_gso(skb) && !skb_gso_validate_network_len(skb, mtu)))) {
netdev_dbg(dev, "packet too big, fragmentation needed\n");
icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
htonl(mtu));
Expand Down

0 comments on commit 9ba1543

Please sign in to comment.