mirror of https://gitee.com/openkylin/linux.git
Merge branch 'bnx2x-disable-GSO-on-too-large-packets'
Daniel Axtens says: ==================== bnx2x: disable GSO on too-large packets We observed a case where a packet received on an ibmveth device had a GSO size of around 10kB. This was forwarded by Open vSwitch to a bnx2x device, where it caused a firmware assert. This is described in detail at [0]. Ultimately we want a fix in the core, but that is very tricky to backport. So for now, just stop the bnx2x driver from crashing. When net-next re-opens I will send the fix to the core and a revert for this. v4 changes: - fix compilation error with EXPORTs (patch 1) - only do slow test if gso_size is greater than 9000 bytes (patch 2) Thanks, Daniel [0]: https://patchwork.ozlabs.org/patch/859410/ ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
26c26ab02c
|
@ -12934,6 +12934,24 @@ static netdev_features_t bnx2x_features_check(struct sk_buff *skb,
|
|||
struct net_device *dev,
|
||||
netdev_features_t features)
|
||||
{
|
||||
/*
|
||||
* A skb with gso_size + header length > 9700 will cause a
|
||||
* firmware panic. Drop GSO support.
|
||||
*
|
||||
* Eventually the upper layer should not pass these packets down.
|
||||
*
|
||||
* For speed, if the gso_size is <= 9000, assume there will
|
||||
* not be 700 bytes of headers and pass it through. Only do a
|
||||
* full (slow) validation if the gso_size is > 9000.
|
||||
*
|
||||
* (Due to the way SKB_BY_FRAGS works this will also do a full
|
||||
* validation in that case.)
|
||||
*/
|
||||
if (unlikely(skb_is_gso(skb) &&
|
||||
(skb_shinfo(skb)->gso_size > 9000) &&
|
||||
!skb_gso_validate_mac_len(skb, 9700)))
|
||||
features &= ~NETIF_F_GSO_MASK;
|
||||
|
||||
features = vlan_features_check(skb, features);
|
||||
return vxlan_features_check(skb, features);
|
||||
}
|
||||
|
|
|
@ -3287,6 +3287,7 @@ 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_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);
|
||||
int skb_ensure_writable(struct sk_buff *skb, int write_len);
|
||||
|
@ -4120,6 +4121,21 @@ static inline unsigned int skb_gso_network_seglen(const struct sk_buff *skb)
|
|||
return hdr_len + skb_gso_transport_seglen(skb);
|
||||
}
|
||||
|
||||
/**
|
||||
* skb_gso_mac_seglen - Return length of individual segments of a gso packet
|
||||
*
|
||||
* @skb: GSO skb
|
||||
*
|
||||
* skb_gso_mac_seglen is used to determine the real size of the
|
||||
* individual segments, including MAC/L2, Layer3 (IP, IPv6) and L4
|
||||
* headers (TCP/UDP).
|
||||
*/
|
||||
static inline unsigned int skb_gso_mac_seglen(const struct sk_buff *skb)
|
||||
{
|
||||
unsigned int hdr_len = skb_transport_header(skb) - skb_mac_header(skb);
|
||||
return hdr_len + skb_gso_transport_seglen(skb);
|
||||
}
|
||||
|
||||
/* Local Checksum Offload.
|
||||
* Compute outer checksum based on the assumption that the
|
||||
* inner checksum will be offloaded later.
|
||||
|
|
|
@ -4913,6 +4913,45 @@ unsigned int skb_gso_transport_seglen(const struct sk_buff *skb)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(skb_gso_transport_seglen);
|
||||
|
||||
/**
|
||||
* skb_gso_size_check - check the skb size, considering GSO_BY_FRAGS
|
||||
*
|
||||
* There are a couple of instances where we have a GSO skb, and we
|
||||
* want to determine what size it would be after it is segmented.
|
||||
*
|
||||
* We might want to check:
|
||||
* - L3+L4+payload size (e.g. IP forwarding)
|
||||
* - L2+L3+L4+payload size (e.g. sanity check before passing to driver)
|
||||
*
|
||||
* This is a helper to do that correctly considering GSO_BY_FRAGS.
|
||||
*
|
||||
* @seg_len: The segmented length (from skb_gso_*_seglen). In the
|
||||
* GSO_BY_FRAGS case this will be [header sizes + GSO_BY_FRAGS].
|
||||
*
|
||||
* @max_len: The maximum permissible length.
|
||||
*
|
||||
* Returns true if the segmented length <= max length.
|
||||
*/
|
||||
static inline bool skb_gso_size_check(const struct sk_buff *skb,
|
||||
unsigned int seg_len,
|
||||
unsigned int max_len) {
|
||||
const struct skb_shared_info *shinfo = skb_shinfo(skb);
|
||||
const struct sk_buff *iter;
|
||||
|
||||
if (shinfo->gso_size != GSO_BY_FRAGS)
|
||||
return seg_len <= max_len;
|
||||
|
||||
/* Undo this so we can re-use header sizes */
|
||||
seg_len -= GSO_BY_FRAGS;
|
||||
|
||||
skb_walk_frags(skb, iter) {
|
||||
if (seg_len + skb_headlen(iter) > max_len)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* skb_gso_validate_mtu - Return in case such skb fits a given MTU
|
||||
*
|
||||
|
@ -4924,27 +4963,25 @@ EXPORT_SYMBOL_GPL(skb_gso_transport_seglen);
|
|||
*/
|
||||
bool skb_gso_validate_mtu(const struct sk_buff *skb, unsigned int mtu)
|
||||
{
|
||||
const struct skb_shared_info *shinfo = skb_shinfo(skb);
|
||||
const struct sk_buff *iter;
|
||||
unsigned int hlen;
|
||||
|
||||
hlen = skb_gso_network_seglen(skb);
|
||||
|
||||
if (shinfo->gso_size != GSO_BY_FRAGS)
|
||||
return hlen <= mtu;
|
||||
|
||||
/* Undo this so we can re-use header sizes */
|
||||
hlen -= GSO_BY_FRAGS;
|
||||
|
||||
skb_walk_frags(skb, iter) {
|
||||
if (hlen + skb_headlen(iter) > mtu)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return skb_gso_size_check(skb, skb_gso_network_seglen(skb), mtu);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(skb_gso_validate_mtu);
|
||||
|
||||
/**
|
||||
* skb_gso_validate_mac_len - Will a split GSO skb fit in a given length?
|
||||
*
|
||||
* @skb: GSO skb
|
||||
* @len: length to validate against
|
||||
*
|
||||
* skb_gso_validate_mac_len validates if a given skb will fit a wanted
|
||||
* length once split, including L2, L3 and L4 headers and the payload.
|
||||
*/
|
||||
bool skb_gso_validate_mac_len(const struct sk_buff *skb, unsigned int len)
|
||||
{
|
||||
return skb_gso_size_check(skb, skb_gso_mac_seglen(skb), len);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(skb_gso_validate_mac_len);
|
||||
|
||||
static struct sk_buff *skb_reorder_vlan_header(struct sk_buff *skb)
|
||||
{
|
||||
if (skb_cow(skb, skb_headroom(skb)) < 0) {
|
||||
|
|
|
@ -142,16 +142,6 @@ static u64 psched_ns_t2l(const struct psched_ratecfg *r,
|
|||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return length of individual segments of a gso packet,
|
||||
* including all headers (MAC, IP, TCP/UDP)
|
||||
*/
|
||||
static unsigned int skb_gso_mac_seglen(const struct sk_buff *skb)
|
||||
{
|
||||
unsigned int hdr_len = skb_transport_header(skb) - skb_mac_header(skb);
|
||||
return hdr_len + skb_gso_transport_seglen(skb);
|
||||
}
|
||||
|
||||
/* GSO packet is too big, segment it so that tbf can transmit
|
||||
* each segment in time
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue