Commit 637d3e99 authored by Hariprasad Shenai's avatar Hariprasad Shenai Committed by David S. Miller

cxgb4: Discard the packet if the length is greater than mtu

pktgen sends raw udp packets and bypasses most of the
linux networking stack. User can specify different packet sizes.
Hence we need to discard the packet if the length is greater than mtu
Signed-off-by: default avatarHariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a3bfb617
...@@ -1120,7 +1120,6 @@ cxgb_fcoe_offload(struct sk_buff *skb, struct adapter *adap, ...@@ -1120,7 +1120,6 @@ cxgb_fcoe_offload(struct sk_buff *skb, struct adapter *adap,
*/ */
netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev) netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
int len;
u32 wr_mid; u32 wr_mid;
u64 cntrl, *end; u64 cntrl, *end;
int qidx, credits; int qidx, credits;
...@@ -1133,6 +1132,7 @@ netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -1133,6 +1132,7 @@ netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev)
const struct skb_shared_info *ssi; const struct skb_shared_info *ssi;
dma_addr_t addr[MAX_SKB_FRAGS + 1]; dma_addr_t addr[MAX_SKB_FRAGS + 1];
bool immediate = false; bool immediate = false;
int len, max_pkt_len;
#ifdef CONFIG_CHELSIO_T4_FCOE #ifdef CONFIG_CHELSIO_T4_FCOE
int err; int err;
#endif /* CONFIG_CHELSIO_T4_FCOE */ #endif /* CONFIG_CHELSIO_T4_FCOE */
...@@ -1146,6 +1146,13 @@ out_free: dev_kfree_skb_any(skb); ...@@ -1146,6 +1146,13 @@ out_free: dev_kfree_skb_any(skb);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
/* Discard the packet if the length is greater than mtu */
max_pkt_len = ETH_HLEN + dev->mtu;
if (skb_vlan_tag_present(skb))
max_pkt_len += VLAN_HLEN;
if (!skb_shinfo(skb)->gso_size && (unlikely(skb->len > max_pkt_len)))
goto out_free;
pi = netdev_priv(dev); pi = netdev_priv(dev);
adap = pi->adapter; adap = pi->adapter;
qidx = skb_get_queue_mapping(skb); qidx = skb_get_queue_mapping(skb);
......
...@@ -1160,7 +1160,7 @@ int t4vf_eth_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -1160,7 +1160,7 @@ int t4vf_eth_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
u32 wr_mid; u32 wr_mid;
u64 cntrl, *end; u64 cntrl, *end;
int qidx, credits; int qidx, credits, max_pkt_len;
unsigned int flits, ndesc; unsigned int flits, ndesc;
struct adapter *adapter; struct adapter *adapter;
struct sge_eth_txq *txq; struct sge_eth_txq *txq;
...@@ -1183,6 +1183,13 @@ int t4vf_eth_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -1183,6 +1183,13 @@ int t4vf_eth_xmit(struct sk_buff *skb, struct net_device *dev)
if (unlikely(skb->len < fw_hdr_copy_len)) if (unlikely(skb->len < fw_hdr_copy_len))
goto out_free; goto out_free;
/* Discard the packet if the length is greater than mtu */
max_pkt_len = ETH_HLEN + dev->mtu;
if (skb_vlan_tag_present(skb))
max_pkt_len += VLAN_HLEN;
if (!skb_shinfo(skb)->gso_size && (unlikely(skb->len > max_pkt_len)))
goto out_free;
/* /*
* Figure out which TX Queue we're going to use. * Figure out which TX Queue we're going to use.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment