Skip to content

Commit

Permalink
net: rename skb_gso_validate_mtu -> skb_gso_validate_network_len
Browse files Browse the repository at this point in the history
If you take a GSO skb, and split it into packets, will the network
length (L3 headers + L4 headers + payload) of those packets be small
enough to fit within a given MTU?

skb_gso_validate_mtu gives you the answer to that question. However,
we recently added to add a way to validate the MAC length of a split GSO
skb (L2+L3+L4+payload), and the names get confusing, so rename
skb_gso_validate_mtu to skb_gso_validate_network_len

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Daniel Axtens authored and David S. Miller committed Mar 4, 2018
1 parent 4e00f5d commit 779b793
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -3286,7 +3286,7 @@ void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len);
int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, int shiftlen);
void skb_scrub_packet(struct sk_buff *skb, bool xnet);
unsigned int skb_gso_transport_seglen(const struct sk_buff *skb);
bool skb_gso_validate_mtu(const struct sk_buff *skb, unsigned int mtu);
bool skb_gso_validate_network_len(const struct sk_buff *skb, unsigned int mtu);
bool skb_gso_validate_mac_len(const struct sk_buff *skb, unsigned int len);
struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features);
struct sk_buff *skb_vlan_untag(struct sk_buff *skb);
Expand Down
11 changes: 6 additions & 5 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -4955,19 +4955,20 @@ static inline bool skb_gso_size_check(const struct sk_buff *skb,
}

/**
* skb_gso_validate_mtu - Return in case such skb fits a given MTU
* skb_gso_validate_network_len - Will a split GSO skb fit into a given MTU?
*
* @skb: GSO skb
* @mtu: MTU to validate against
*
* skb_gso_validate_mtu validates if a given skb will fit a wanted MTU
* once split.
* skb_gso_validate_network_len validates if a given skb will fit a
* wanted MTU once split. It considers L3 headers, L4 headers, and the
* payload.
*/
bool skb_gso_validate_mtu(const struct sk_buff *skb, unsigned int mtu)
bool skb_gso_validate_network_len(const struct sk_buff *skb, unsigned int mtu)
{
return skb_gso_size_check(skb, skb_gso_network_seglen(skb), mtu);
}
EXPORT_SYMBOL_GPL(skb_gso_validate_mtu);
EXPORT_SYMBOL_GPL(skb_gso_validate_network_len);

/**
* skb_gso_validate_mac_len - Will a split GSO skb fit in a given length?
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/ip_forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static bool ip_exceeds_mtu(const struct sk_buff *skb, unsigned int mtu)
if (skb->ignore_df)
return false;

if (skb_is_gso(skb) && skb_gso_validate_mtu(skb, mtu))
if (skb_is_gso(skb) && skb_gso_validate_network_len(skb, mtu))
return false;

return true;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/ip_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ static int ip_finish_output_gso(struct net *net, struct sock *sk,

/* common case: seglen is <= mtu
*/
if (skb_gso_validate_mtu(skb, mtu))
if (skb_gso_validate_network_len(skb, mtu))
return ip_finish_output2(net, sk, skb);

/* Slowpath - GSO segment length exceeds the egress MTU.
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/nf_flow_table_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static bool __nf_flow_exceeds_mtu(const struct sk_buff *skb, unsigned int mtu)
if ((ip_hdr(skb)->frag_off & htons(IP_DF)) == 0)
return false;

if (skb_is_gso(skb) && skb_gso_validate_mtu(skb, mtu))
if (skb_is_gso(skb) && skb_gso_validate_network_len(skb, mtu))
return false;

return true;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/ip6_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ static bool ip6_pkt_too_big(const struct sk_buff *skb, unsigned int mtu)
if (skb->ignore_df)
return false;

if (skb_is_gso(skb) && skb_gso_validate_mtu(skb, mtu))
if (skb_is_gso(skb) && skb_gso_validate_network_len(skb, mtu))
return false;

return true;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/nf_flow_table_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static bool __nf_flow_exceeds_mtu(const struct sk_buff *skb, unsigned int mtu)
if (skb->len <= mtu)
return false;

if (skb_is_gso(skb) && skb_gso_validate_mtu(skb, mtu))
if (skb_is_gso(skb) && skb_gso_validate_network_len(skb, mtu))
return false;

return true;
Expand Down
2 changes: 1 addition & 1 deletion net/mpls/af_mpls.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ bool mpls_pkt_too_big(const struct sk_buff *skb, unsigned int mtu)
if (skb->len <= mtu)
return false;

if (skb_is_gso(skb) && skb_gso_validate_mtu(skb, mtu))
if (skb_is_gso(skb) && skb_gso_validate_network_len(skb, mtu))
return false;

return true;
Expand Down
2 changes: 1 addition & 1 deletion net/xfrm/xfrm_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
if (skb->len <= mtu)
goto ok;

if (skb_is_gso(skb) && skb_gso_validate_mtu(skb, mtu))
if (skb_is_gso(skb) && skb_gso_validate_network_len(skb, mtu))
goto ok;
}

Expand Down

0 comments on commit 779b793

Please sign in to comment.