igb: pass the correct maxlen for eth_get_headlen()
Subsystems (3)
PATCH 1/1 igb: pass the correct maxlen for eth_get_headlen()
The second parameter of eth_get_headlen() is the length of the frame buffer, not the header length of skb.
--- drivers/net/ethernet/intel/igb/igb_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/igb/igb_main.c +3 -1
@@ -6852,7 +6852,9 @@ static void igb_pull_tail(struct igb_ring *rx_ring,/* we need the header to contain the greater of either ETH_HLEN or * 60 bytes if the skb->len is less than 60 for skb_pad. */ - pull_len =eth_get_headlen (va,IGB_RX_HDR_LEN ); + pull_len =eth_get_headlen (va,skb_frag_size (frag)); +if (unlikely (pull_len >IGB_RX_HDR_LEN )) + pull_len =IGB_RX_HDR_LEN ;/* align pull length to size of long to optimize memcpy performance */ skb_copy_to_linear_data (skb, va,ALIGN (pull_len,sizeof (long )));
Signature · 1 line
1.8.3.1
PATCH 1/1 fm10k: pass the correct maxlen for eth_get_headlen()
The second parameter of eth_get_headlen() is the length of the frame buffer, not the header length of skb.
--- drivers/net/ethernet/intel/fm10k/fm10k_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/fm10k/fm10k_main.c +3 -1
@@ -543,7 +543,9 @@ static void fm10k_pull_tail(struct sk_buff *skb)/* we need the header to contain the greater of either ETH_HLEN or * 60 bytes if the skb->len is less than 60 for skb_pad. */ - pull_len =eth_get_headlen (va,FM10K_RX_HDR_LEN ); + pull_len =eth_get_headlen (va,skb_frag_size (frag)); +if (unlikely (pull_len >FM10K_RX_HDR_LEN )) + pull_len =FM10K_RX_HDR_LEN ;/* align pull length to size of long to optimize memcpy performance */ skb_copy_to_linear_data (skb, va,ALIGN (pull_len,sizeof (long )));
Signature · 1 line
1.8.3.1
PATCH 1/1 ixgbe: pass the correct maxlen for eth_get_headlen()
In reply to Cong WangThe second parameter of eth_get_headlen() is the length of the frame buffer, not the header length of skb.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +3 -1
@@ -1707,7 +1707,9 @@ static void ixgbe_pull_tail(struct ixgbe_ring *rx_ring,* we need the header to contain the greater of either ETH_HLEN or * 60 bytes if the skb->len is less than 60 for skb_pad. */ - pull_len =eth_get_headlen (va,IXGBE_RX_HDR_SIZE ); + pull_len =eth_get_headlen (va,skb_frag_size (frag)); +if (unlikely (pull_len >IXGBE_RX_HDR_SIZE )) + pull_len =IXGBE_RX_HDR_SIZE ;/* align pull length to size of long to optimize memcpy performance */ skb_copy_to_linear_data (skb, va,ALIGN (pull_len,sizeof (long )));
Signature · 1 line
1.8.3.1
PATCH 1/1 ixgbevf: pass the correct maxlen for eth_get_headlen()
In reply to Cong WangThe second parameter of eth_get_headlen() is the length of the frame buffer, not the header length of skb.
--- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +3 -1
@@ -676,7 +676,9 @@ static void ixgbevf_pull_tail(struct ixgbevf_ring *rx_ring,/* we need the header to contain the greater of either ETH_HLEN or * 60 bytes if the skb->len is less than 60 for skb_pad. */ - pull_len =eth_get_headlen (va,IXGBEVF_RX_HDR_SIZE ); + pull_len =eth_get_headlen (va,skb_frag_size (frag)); +if (unlikely (pull_len >IXGBEVF_RX_HDR_SIZE )) + pull_len =IXGBEVF_RX_HDR_SIZE ;/* align pull length to size of long to optimize memcpy performance */ skb_copy_to_linear_data (skb, va,ALIGN (pull_len,sizeof (long )));
Signature · 1 line
1.8.3.1
Quoted 14 lines · Cong Wang
The second parameter of
eth_get_headlen()is the length of the frame buffer, not the header length of skb.Cc Jeff Kirsher <[email protected]>Signed-off-by Cong Wang <[email protected]>--- drivers/net/ethernet/intel/igb/igb_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/igb/igb_main.c +0
-0
drivers/net/ethernet/intel/igb/igb_main.c static void igb_pull_tail(struct igb_ring *rx_ring, · line 6860
Quoted 10 lines
drivers/net/ethernet/intel/igb/igb_main.c +3
-1@@ -6852,7 +6852,9 @@ static void igb_pull_tail(struct igb_ring *rx_ring,/* we need the header to contain the greater of either ETH_HLEN or * 60 bytes if the skb->len is less than 60 for skb_pad. */ - pull_len =eth_get_headlen (va,IGB_RX_HDR_LEN ); + pull_len =eth_get_headlen (va,skb_frag_size (frag)); +if (unlikely (pull_len >IGB_RX_HDR_LEN )) + pull_len =IGB_RX_HDR_LEN ;/* align pull length to size of long to optimize memcpy performance */ skb_copy_to_linear_data (skb, va,ALIGN (pull_len,sizeof (long )));
You have this part right. The length represents the maximum length we are willing to traverse in the buffer. So if we 100% want to get the entire header regardless of what we can copy into then we could follow your approach. However, since the allocated space in the skb is only IGB_RX_HDR_LEN we only really want to traverse up to that length. Then that is all we copy out of the header.
As a result we don't need the extra code for putting the upper limit on pull_len since that is factored in by passing IGB_RX_HDR_LEN as the maximum traversal length.
- Alex
Quoted 23 lines · Alexander Duyck
Quoted 22 lines · Cong Wang
The second parameter of
eth_get_headlen()is the length of the frame buffer, not the header length of skb.Cc Jeff Kirsher <[email protected]>Signed-off-by Cong Wang <[email protected]>--- drivers/net/ethernet/intel/igb/igb_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/igb/igb_main.c +3
-1@@ -6852,7 +6852,9 @@ static void igb_pull_tail(struct igb_ring *rx_ring,/* we need the header to contain the greater of either ETH_HLEN or * 60 bytes if the skb->len is less than 60 for skb_pad. */ - pull_len =eth_get_headlen (va,IGB_RX_HDR_LEN ); + pull_len =eth_get_headlen (va,skb_frag_size (frag)); +if (unlikely (pull_len >IGB_RX_HDR_LEN )) + pull_len =IGB_RX_HDR_LEN ;
Quoted 9 lines
drivers/net/ethernet/intel/igb/igb_main.c static void igb_pull_tail(struct igb_ring *rx_ring, · line 6860
Quoted 2 lines
drivers/net/ethernet/intel/igb/igb_main.c +0
-0/* align pull length to size of long to optimize memcpy performance */ skb_copy_to_linear_data (skb, va,ALIGN (pull_len,sizeof (long )));You have this part right. The length represents the maximum length we are willing to traverse in the buffer. So if we 100% want to get the entire header regardless of what we can copy into then we could follow your approach. However, since the allocated space in the skb is only
IGB_RX_HDR_LENwe only really want to traverse up to that length. Then that is all we copy out of the header.
But the frag size could be smaller than IGB_RX_HDR_LEN which is the case this patch tries to fix.
Quoted 4 lines
As a result we don't need the extra code for putting the upper limit on
pull_lensince that is factored in by passingIGB_RX_HDR_LENas the maximum traversal length.
That is why I put unlikely() there, even with tunnel headers we unlikely pull header longer than IGB_RX_HDR_LEN, the code is just for completeness.
Quoted 33 lines · Cong Wang
Quoted 23 lines · Alexander Duyck
Quoted 22 lines · Cong Wang
The second parameter of
eth_get_headlen()is the length of the frame buffer, not the header length of skb.Cc Jeff Kirsher <[email protected]>Signed-off-by Cong Wang <[email protected]>--- drivers/net/ethernet/intel/igb/igb_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/igb/igb_main.c +3
-1@@ -6852,7 +6852,9 @@ static void igb_pull_tail(struct igb_ring *rx_ring,/* we need the header to contain the greater of either ETH_HLEN or * 60 bytes if the skb->len is less than 60 for skb_pad. */ - pull_len =eth_get_headlen (va,IGB_RX_HDR_LEN ); + pull_len =eth_get_headlen (va,skb_frag_size (frag)); +if (unlikely (pull_len >IGB_RX_HDR_LEN )) + pull_len =IGB_RX_HDR_LEN ;Quoted 8 lines
drivers/net/ethernet/intel/igb/igb_main.c static void igb_pull_tail(struct igb_ring *rx_ring, · line 6860
Quoted 2 lines
drivers/net/ethernet/intel/igb/igb_main.c +0
-0/* align pull length to size of long to optimize memcpy performance */ skb_copy_to_linear_data (skb, va,ALIGN (pull_len,sizeof (long )));You have this part right. The length represents the maximum length we are willing to traverse in the buffer. So if we 100% want to get the entire header regardless of what we can copy into then we could follow your approach. However, since the allocated space in the skb is only
IGB_RX_HDR_LENwe only really want to traverse up to that length. Then that is all we copy out of the header.
Quoted 2 lines
But the frag size could be smaller than
IGB_RX_HDR_LENwhich is the case this patch tries to fix.
No it can't. We only add frags if the first frag is larger than IGB_RX_HDR_LEN. Go look at the code where this driver calls add_rx_frag. You should find there is copybreak code in there that kicks in for anything less than or equal to IGB_RX_HDR_LEN in size on the first frag. It is there to allow us to avoid having to perform an atomic inc/dec on the page.
Quoted 6 lines
Quoted 3 lines
As a result we don't need the extra code for putting the upper limit on
pull_lensince that is factored in by passingIGB_RX_HDR_LENas the maximum traversal length.That is why I put
unlikely()there, even with tunnel headers we unlikely pull header longer thanIGB_RX_HDR_LEN, the code is just for completeness.
The code is fine as is. I suggest you go look at the code where frags are attached to the sk_buff.
- Alex
Quoted 37 lines · Alexander Duyck
Quoted 33 lines · Cong Wang
Quoted 23 lines · Alexander Duyck
Quoted 22 lines · Cong Wang
The second parameter of
eth_get_headlen()is the length of the frame buffer, not the header length of skb.Cc Jeff Kirsher <[email protected]>Signed-off-by Cong Wang <[email protected]>--- drivers/net/ethernet/intel/igb/igb_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/igb/igb_main.c +3
-1@@ -6852,7 +6852,9 @@ static void igb_pull_tail(struct igb_ring *rx_ring,/* we need the header to contain the greater of either ETH_HLEN or * 60 bytes if the skb->len is less than 60 for skb_pad. */ - pull_len =eth_get_headlen (va,IGB_RX_HDR_LEN ); + pull_len =eth_get_headlen (va,skb_frag_size (frag)); +if (unlikely (pull_len >IGB_RX_HDR_LEN )) + pull_len =IGB_RX_HDR_LEN ;Quoted 8 lines
drivers/net/ethernet/intel/igb/igb_main.c static void igb_pull_tail(struct igb_ring *rx_ring, · line 6860
Quoted 2 lines
drivers/net/ethernet/intel/igb/igb_main.c +0
-0/* align pull length to size of long to optimize memcpy performance */ skb_copy_to_linear_data (skb, va,ALIGN (pull_len,sizeof (long )));You have this part right. The length represents the maximum length we are willing to traverse in the buffer. So if we 100% want to get the entire header regardless of what we can copy into then we could follow your approach. However, since the allocated space in the skb is only
IGB_RX_HDR_LENwe only really want to traverse up to that length. Then that is all we copy out of the header.Quoted 2 lines
But the frag size could be smaller than
IGB_RX_HDR_LENwhich is the case this patch tries to fix.
Quoted 7 lines
No it can't. We only add frags if the first frag is larger than
IGB_RX_HDR_LEN. Go look at the code where this driver callsadd_rx_frag. You should find there is copybreak code in there that kicks in for anything less than or equal toIGB_RX_HDR_LENin size on the first frag. It is there to allow us to avoid having to perform an atomic inc/dec on the page.
First, make sure you don't miss the TSIP case right above:
The frag starting pointer and its size are advanced by:
skb_frag_size_sub(frag, IGB_TS_HDR_LEN);
...
va += IGB_TS_HDR_LEN;
even though we unlikely pull header longer thanIGB_RX_HDR_LEN - IGB_TS_HDR_LEN either.
Second, the check you mentioned above is:
if ((size <= IGB_RX_HDR_LEN) && !skb_is_nonlinear(skb))
skb is nonlinear _after_ the first igb_add_rx_frag(), a second igb_add_rx_frag() is possible since igb_is_non_eop() could return true.
Quoted 47 lines · Cong Wang
Quoted 34 lines · Alexander Duyck
Quoted 33 lines · Cong Wang
Quoted 31 lines · Alexander Duyck
Quoted 14 lines · Cong Wang
The second parameter of
eth_get_headlen()is the length of the frame buffer, not the header length of skb.Cc Jeff Kirsher <[email protected]>Signed-off-by Cong Wang <[email protected]>--- drivers/net/ethernet/intel/igb/igb_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/igb/igb_main.c +0
-0drivers/net/ethernet/intel/igb/igb_main.c static void igb_pull_tail(struct igb_ring *rx_ring, · line 6860
Quoted 10 lines
drivers/net/ethernet/intel/igb/igb_main.c +3
-1@@ -6852,7 +6852,9 @@ static void igb_pull_tail(struct igb_ring *rx_ring,/* we need the header to contain the greater of either ETH_HLEN or * 60 bytes if the skb->len is less than 60 for skb_pad. */ - pull_len =eth_get_headlen (va,IGB_RX_HDR_LEN ); + pull_len =eth_get_headlen (va,skb_frag_size (frag)); +if (unlikely (pull_len >IGB_RX_HDR_LEN )) + pull_len =IGB_RX_HDR_LEN ;/* align pull length to size of long to optimize memcpy performance */ skb_copy_to_linear_data (skb, va,ALIGN (pull_len,sizeof (long )));You have this part right. The length represents the maximum length we are willing to traverse in the buffer. So if we 100% want to get the entire header regardless of what we can copy into then we could follow your approach. However, since the allocated space in the skb is only
IGB_RX_HDR_LENwe only really want to traverse up to that length. Then that is all we copy out of the header.Quoted 9 lines
Quoted 2 lines
But the frag size could be smaller than
IGB_RX_HDR_LENwhich is the case this patch tries to fix.No it can't. We only add frags if the first frag is larger than
IGB_RX_HDR_LEN. Go look at the code where this driver callsadd_rx_frag. You should find there is copybreak code in there that kicks in for anything less than or equal toIGB_RX_HDR_LENin size on the first frag. It is there to allow us to avoid having to perform an atomic inc/dec on the page.First, make sure you don't miss the TSIP case right above:
Quoted 8 lines
The frag starting pointer and its size are advanced by:
skb_frag_size_sub(frag, IGB_TS_HDR_LEN);
...
va +=IGB_TS_HDR_LEN;even though we unlikely pull header longer than
IGB_RX_HDR_LEN-IGB_TS_HDR_LENeither.
So I believe this is a possible bug, one heck of a corner case to get into though. It requires timestamp in packet, size 240 - 256, and a malformed header.
The proper fix would probably be to pull the timestamp out of the packet before we add it to the frame. I'll submit a patch to address this.
Quoted 8 lines
Second, the check you mentioned above is:
if ((size <=
IGB_RX_HDR_LEN) && !skb_is_nonlinear(skb))skb is nonlinear _after_ the first
igb_add_rx_frag(), a secondigb_add_rx_frag()is possible sinceigb_is_non_eop()could return true.
I'm not sure this part makes any sense. We pull the data out of the first fragment always. If skb_is_nonlinear is set then we should have at least 2K - 16B in the case of igb. We will never have a second fragment without at least 2K of data being given in the first.
- Alex
Quoted 12 lines · Alexander Duyck
Quoted 10 lines · Cong Wang
First, make sure you don't miss the TSIP case right above:
The frag starting pointer and its size are advanced by:
skb_frag_size_sub(frag, IGB_TS_HDR_LEN);
...
va +=IGB_TS_HDR_LEN;even though we unlikely pull header longer than
IGB_RX_HDR_LEN-IGB_TS_HDR_LENeither.
Quoted 7 lines
So I believe this is a possible bug, one heck of a corner case to get into though. It requires timestamp in packet, size 240 - 256, and a malformed header.
The proper fix would probably be to pull the timestamp out of the packet before we add it to the frame. I'll submit a patch to address this.
Huh? Doesn't my patch already fix this? skb_frag_size() is always up to date. Or you mean another different problem?
Quoted 5 lines
Quoted 5 lines
Second, the check you mentioned above is:
if ((size <=
IGB_RX_HDR_LEN) && !skb_is_nonlinear(skb))
Quoted 8 lines
Quoted 3 lines
skb is nonlinear _after_ the first
igb_add_rx_frag(), a secondigb_add_rx_frag()is possible sinceigb_is_non_eop()could return true.I'm not sure this part makes any sense. We pull the data out of the first fragment always. If
skb_is_nonlinearis set then we should have at least 2K - 16B in the case of igb. We will never have a second fragment without at least 2K of data being given in the first.
Apparently my igb knowledge isn't enough to verify this, I just did logical analysis.
Quoted 17 lines · Cong Wang
Quoted 15 lines · Alexander Duyck
Quoted 10 lines · Cong Wang
First, make sure you don't miss the TSIP case right above:
The frag starting pointer and its size are advanced by:
skb_frag_size_sub(frag, IGB_TS_HDR_LEN);
...
va +=IGB_TS_HDR_LEN;even though we unlikely pull header longer than
IGB_RX_HDR_LEN-IGB_TS_HDR_LENeither.So I believe this is a possible bug, one heck of a corner case to get into though. It requires timestamp in packet, size 240 - 256, and a malformed header.
Quoted 6 lines
Quoted 3 lines
The proper fix would probably be to pull the timestamp out of the packet before we add it to the frame. I'll submit a patch to address this.
Huh? Doesn't my patch already fix this?
skb_frag_size()is always up to date. Or you mean another different problem?
Your patch has other issues. I am still NAKing your patch, but there is an issue with igb that you have pointed out. The proper fix would be to deal with the timestamp before we add the page fragment to the skb.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Second, the check you mentioned above is:
if ((size <=
IGB_RX_HDR_LEN) && !skb_is_nonlinear(skb))skb is nonlinear _after_ the first
igb_add_rx_frag(), a secondigb_add_rx_frag()is possible sinceigb_is_non_eop()could return true.
Quoted 6 lines
Quoted 4 lines
I'm not sure this part makes any sense. We pull the data out of the first fragment always. If
skb_is_nonlinearis set then we should have at least 2K - 16B in the case of igb. We will never have a second fragment without at least 2K of data being given in the first.Apparently my igb knowledge isn't enough to verify this, I just did logical analysis.
The logic with igb is that if skb_is_nonlinear it means that a page has already been added. The way the hardware works is that it will break a frame up into 2K segments until the entire frame is written. So the only way to get a second page fragment is if the first has used the entire 2K buffer it was given.
- Alex
Quoted 22 lines · Alexander Duyck
Quoted 21 lines · Cong Wang
Quoted 18 lines · Alexander Duyck
Quoted 10 lines · Cong Wang
First, make sure you don't miss the TSIP case right above:
The frag starting pointer and its size are advanced by:
skb_frag_size_sub(frag, IGB_TS_HDR_LEN);
...
va +=IGB_TS_HDR_LEN;even though we unlikely pull header longer than
IGB_RX_HDR_LEN-IGB_TS_HDR_LENeither.So I believe this is a possible bug, one heck of a corner case to get into though. It requires timestamp in packet, size 240 - 256, and a malformed header.
The proper fix would probably be to pull the timestamp out of the packet before we add it to the frame. I'll submit a patch to address this.
Quoted 7 lines
Quoted 2 lines
Huh? Doesn't my patch already fix this?
skb_frag_size()is always up to date. Or you mean another different problem?Your patch has other issues. I am still NAKing your patch, but there is an issue with igb that you have pointed out. The proper fix would be to deal with the timestamp before we add the page fragment to the skb.
If the first frag is always 2K, then this is not a problem either. IGB_TS_HDR_LEN + IGB_RX_HDR_LEN < 2K.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
Second, the check you mentioned above is:
if ((size <=
IGB_RX_HDR_LEN) && !skb_is_nonlinear(skb))skb is nonlinear _after_ the first
igb_add_rx_frag(), a secondigb_add_rx_frag()is possible sinceigb_is_non_eop()could return true.I'm not sure this part makes any sense. We pull the data out of the first fragment always. If
skb_is_nonlinearis set then we should have at least 2K - 16B in the case of igb. We will never have a second fragment without at least 2K of data being given in the first.
Quoted 8 lines
Quoted 2 lines
Apparently my igb knowledge isn't enough to verify this, I just did logical analysis.
The logic with igb is that if
skb_is_nonlinearit means that a page has already been added. The way the hardware works is that it will break a frame up into 2K segments until the entire frame is written. So the only way to get a second page fragment is if the first has used the entire 2K buffer it was given.
So the first frag is always 2K, at least more than IGB_RX_HDR_LEN then we are fine even for TSIP case.
The code looks correct to me now, except it is suspicious skb->len is not updated after skb_copy_to_linear_data() while skb->tail is advanced already. I need to think more before submitting a patch.
Quoted 23 lines · Cong Wang
Quoted 21 lines · Alexander Duyck
Quoted 20 lines · Cong Wang
Quoted 18 lines · Alexander Duyck
Quoted 10 lines · Cong Wang
First, make sure you don't miss the TSIP case right above:
The frag starting pointer and its size are advanced by:
skb_frag_size_sub(frag, IGB_TS_HDR_LEN);
...
va +=IGB_TS_HDR_LEN;even though we unlikely pull header longer than
IGB_RX_HDR_LEN-IGB_TS_HDR_LENeither.So I believe this is a possible bug, one heck of a corner case to get into though. It requires timestamp in packet, size 240 - 256, and a malformed header.
The proper fix would probably be to pull the timestamp out of the packet before we add it to the frame. I'll submit a patch to address this.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Huh? Doesn't my patch already fix this?
skb_frag_size()is always up to date. Or you mean another different problem?Your patch has other issues. I am still NAKing your patch, but there is an issue with igb that you have pointed out. The proper fix would be to deal with the timestamp before we add the page fragment to the skb.
If the first frag is always 2K, then this is not a problem either.
IGB_TS_HDR_LEN+IGB_RX_HDR_LEN< 2K.
The problem is skb->tail will get screwed up.
Quoted 19 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
Second, the check you mentioned above is:
if ((size <=
IGB_RX_HDR_LEN) && !skb_is_nonlinear(skb))skb is nonlinear _after_ the first
igb_add_rx_frag(), a secondigb_add_rx_frag()is possible sinceigb_is_non_eop()could return true.I'm not sure this part makes any sense. We pull the data out of the first fragment always. If
skb_is_nonlinearis set then we should have at least 2K - 16B in the case of igb. We will never have a second fragment without at least 2K of data being given in the first.Quoted 7 lines
Quoted 2 lines
Apparently my igb knowledge isn't enough to verify this, I just did logical analysis.
The logic with igb is that if
skb_is_nonlinearit means that a page has already been added. The way the hardware works is that it will break a frame up into 2K segments until the entire frame is written. So the only way to get a second page fragment is if the first has used the entire 2K buffer it was given.
Quoted 6 lines
So the first frag is always 2K, at least more than
IGB_RX_HDR_LENthen we are fine even for TSIP case.The code looks correct to me now, except it is suspicious
skb->lenis not updated afterskb_copy_to_linear_data()whileskb->tailis advanced already. I need to think more before submitting a patch.
The first frag will be 2K in size only if there are multiple frags. The problem in the TSIP case is that we will put the size reported by the descriptor into the fragment, and then try to pull the size we determined via eth_get_headlen. So there is a window where that value can be wrong and result in data_len going negative and tail being moved beyond the end of the actual data.
- Alex
Quoted 26 lines · Alexander Duyck
Quoted 25 lines · Cong Wang
Quoted 23 lines · Alexander Duyck
Quoted 22 lines · Cong Wang
Quoted 9 lines · Alexander Duyck
Quoted 8 lines · Cong Wang
First, make sure you don't miss the TSIP case right above:
The frag starting pointer and its size are advanced by:
skb_frag_size_sub(frag, IGB_TS_HDR_LEN);
...
va +=IGB_TS_HDR_LEN;Quoted 9 lines
Quoted 2 lines
even though we unlikely pull header longer than
IGB_RX_HDR_LEN-IGB_TS_HDR_LENeither.So I believe this is a possible bug, one heck of a corner case to get into though. It requires timestamp in packet, size 240 - 256, and a malformed header.
The proper fix would probably be to pull the timestamp out of the packet before we add it to the frame. I'll submit a patch to address this.
Huh? Doesn't my patch already fix this?
skb_frag_size()is always up to date. Or you mean another different problem?
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Your patch has other issues. I am still NAKing your patch, but there is an issue with igb that you have pointed out. The proper fix would be to deal with the timestamp before we add the page fragment to the skb.
If the first frag is always 2K, then this is not a problem either.
IGB_TS_HDR_LEN+IGB_RX_HDR_LEN< 2K.The problem is
skb->tailwill get screwed up.
Why? We don't copy timestamp into skb header, instead it is saved in shared_info, why skb->tail matters here in TSIP case?
[...]
Quoted 2 lines
The first frag will be 2K in size only if there are multiple frags. The
Or it doesn't have frags at all since we just copy it to skb header, right?
Quoted 2 lines
problem in the TSIP case is that we will put the size reported by the descriptor into the fragment, and then try to pull the size we
That size is saved when adding the frag, in TSIP case we just sub it by IGB_TS_HDR_LEN, which seems correct.
Quoted 3 lines
determined via
eth_get_headlen. So there is a window where that value can be wrong and result indata_lengoing negative and tail being moved beyond the end of the actual data.
This sounds like a different problem if you are saying we should sub the size in the descriptor too. Therefore I don't see why your patch could replace mine.
Quoted 32 lines · Cong Wang
Quoted 30 lines · Alexander Duyck
Quoted 29 lines · Cong Wang
Quoted 27 lines · Alexander Duyck
Quoted 17 lines · Cong Wang
Quoted 15 lines · Alexander Duyck
Quoted 10 lines · Cong Wang
First, make sure you don't miss the TSIP case right above:
The frag starting pointer and its size are advanced by:
skb_frag_size_sub(frag, IGB_TS_HDR_LEN);
...
va +=IGB_TS_HDR_LEN;even though we unlikely pull header longer than
IGB_RX_HDR_LEN-IGB_TS_HDR_LENeither.So I believe this is a possible bug, one heck of a corner case to get into though. It requires timestamp in packet, size 240 - 256, and a malformed header.
Quoted 5 lines
Quoted 3 lines
The proper fix would probably be to pull the timestamp out of the packet before we add it to the frame. I'll submit a patch to address this.
Huh? Doesn't my patch already fix this?
skb_frag_size()is always up to date. Or you mean another different problem?Your patch has other issues. I am still NAKing your patch, but there is an issue with igb that you have pointed out. The proper fix would be to deal with the timestamp before we add the page fragment to the skb.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
If the first frag is always 2K, then this is not a problem either.
IGB_TS_HDR_LEN+IGB_RX_HDR_LEN< 2K.The problem is
skb->tailwill get screwed up.Why? We don't copy timestamp into skb header, instead it is saved in
shared_info, whyskb->tailmatters here in TSIP case?
TSIP only matters if you have a network header with bad data in it that indicates the size is actually larger than it actually is.
Quoted 3 lines
Quoted 1 line
The first frag will be 2K in size only if there are multiple frags. The
Or it doesn't have frags at all since we just copy it to skb header, right?
That is moot since this code only gets called if the skb is nonlinear
Quoted 6 lines
Quoted 2 lines
problem in the TSIP case is that we will put the size reported by the descriptor into the fragment, and then try to pull the size we
That size is saved when adding the frag, in TSIP case we just sub it by
IGB_TS_HDR_LEN, which seems correct.
Yes, the size is saved. But with your solution we could pull the whole fragment but not free it which isn't correct as we shouldn't be left with any 0 sized fragments.
Quoted 6 lines
Quoted 3 lines
determined via
eth_get_headlen. So there is a window where that value can be wrong and result indata_lengoing negative and tail being moved beyond the end of the actual data.This sounds like a different problem if you are saying we should sub the size in the descriptor too. Therefore I don't see why your patch could replace mine.
Your patches sort-of fixed the problem, but they introduced other issues in the process.
The thing I don't think you are getting is that the code was meant to be mutually exclusive w/ the copy-break code. Either the frag is less than IGB_RX_HDR_SIZE in which case we copy-break and don't attached the fragment, or we should be pulling the header and leaving at least 1 byte in the fragment. The problem with your solution is that you potentially pull the entire fragment in, but you don't free it if the size drops to
0. That is why in the other mail I told you the better solution for igb would likely be to just pass IGB_RX_HDR_SIZE - IGB_TS_HDR_SIZE as that way you end up with at least 1 byte left in the fragment after you pull the header.
- Alex
Quoted 35 lines · Alexander Duyck
Quoted 34 lines · Cong Wang
Quoted 32 lines · Alexander Duyck
Quoted 31 lines · Cong Wang
Quoted 18 lines · Alexander Duyck
Quoted 17 lines · Cong Wang
Quoted 15 lines · Alexander Duyck
Quoted 10 lines · Cong Wang
First, make sure you don't miss the TSIP case right above:
The frag starting pointer and its size are advanced by:
skb_frag_size_sub(frag, IGB_TS_HDR_LEN);
...
va +=IGB_TS_HDR_LEN;even though we unlikely pull header longer than
IGB_RX_HDR_LEN-IGB_TS_HDR_LENeither.So I believe this is a possible bug, one heck of a corner case to get into though. It requires timestamp in packet, size 240 - 256, and a malformed header.
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
The proper fix would probably be to pull the timestamp out of the packet before we add it to the frame. I'll submit a patch to address this.
Huh? Doesn't my patch already fix this?
skb_frag_size()is always up to date. Or you mean another different problem?Your patch has other issues. I am still NAKing your patch, but there is an issue with igb that you have pointed out. The proper fix would be to deal with the timestamp before we add the page fragment to the skb.
If the first frag is always 2K, then this is not a problem either.
IGB_TS_HDR_LEN+IGB_RX_HDR_LEN< 2K.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The problem is
skb->tailwill get screwed up.Why? We don't copy timestamp into skb header, instead it is saved in
shared_info, whyskb->tailmatters here in TSIP case?TSIP only matters if you have a network header with bad data in it that indicates the size is actually larger than it actually is.
OK.
Quoted 10 lines
Quoted 4 lines
Quoted 2 lines
The first frag will be 2K in size only if there are multiple frags. The
Or it doesn't have frags at all since we just copy it to skb header, right?
That is moot since this code only gets called if the skb is nonlinear
Quoted 3 lines
Quoted 2 lines
problem in the TSIP case is that we will put the size reported by the descriptor into the fragment, and then try to pull the size we
Quoted 7 lines
Quoted 3 lines
That size is saved when adding the frag, in TSIP case we just sub it by
IGB_TS_HDR_LEN, which seems correct.Yes, the size is saved. But with your solution we could pull the whole fragment but not free it which isn't correct as we shouldn't be left with any 0 sized fragments.
Good point, then TSIP case should check frag_size == 0 case, the rest handles 0-size case correctly, see below.
Quoted 11 lines
Quoted 7 lines
Quoted 4 lines
determined via
eth_get_headlen. So there is a window where that value can be wrong and result indata_lengoing negative and tail being moved beyond the end of the actual data.This sounds like a different problem if you are saying we should sub the size in the descriptor too. Therefore I don't see why your patch could replace mine.
Your patches sort-of fixed the problem, but they introduced other issues in the process.
Quoted 6 lines
The thing I don't think you are getting is that the code was meant to be mutually exclusive w/ the copy-break code. Either the frag is less than
IGB_RX_HDR_SIZEin which case we copy-break and don't attached the fragment, or we should be pulling the header and leaving at least 1 byte in the fragment. The problem with your solution is that you potentially pull the entire fragment in, but you don't free it if the size drops to
Only if it is a malformed packet, and it is still safe as long as we don't run over the buffer size. Also I have a upper limit check for IGB_RX_HDR_SIZE after eth_get_headlen().
Quoted 1 line
0. That is why in the other mail I told you the better solution for igb
I am sure eth_get_headlen() handles 0 case correctly, it simply returns 0.
Quoted 4 lines
would likely be to just pass
IGB_RX_HDR_SIZE-IGB_TS_HDR_SIZEas that way you end up with at least 1 byte left in the fragment after you pull the header.
The code should already handle pull_len==0 correctly.
(Off-topic...)
Quoted 4 lines · Cong Wang
The code looks correct to me now, except it is suspicious
skb->lenis not updated afterskb_copy_to_linear_data()whileskb->tailis advanced already. I need to think more before submitting a patch.
I feel like we need the following patch, maybe skb->len is updated somewhere else by "skb->tail - skb->head", otherwise we are screwed?
(quoted diff) +0 -0
b/drivers/net/ethernet/intel/igb/igb_main.c
index a0a9b1f..66e6fb6 100644
drivers/net/ethernet/intel/igb/igb_main.c +1 -2
@@ -6843,7 +6843,6 @@ static void igb_pull_tail(struct igb_ring *rx_ring,skb_frag_size_sub (frag,IGB_TS_HDR_LEN ); frag->page_offset +=IGB_TS_HDR_LEN ; skb->data_len -=IGB_TS_HDR_LEN ; - skb->len -=IGB_TS_HDR_LEN ;/* move va to start of packet data */ va +=IGB_TS_HDR_LEN ;
@@ -6856,12 +6855,12 @@ static void igb_pull_tail(struct igb_ring *rx_ring,/* align pull length to size of long to optimize memcpy performance */ skb_copy_to_linear_data (skb, va,ALIGN (pull_len,sizeof (long ))); +__skb_put (skb, pull_len);/* update all of the pointers */ skb_frag_size_sub (frag, pull_len); frag->page_offset += pull_len; skb->data_len -= pull_len; - skb->tail += pull_len; }/**
Quoted 8 lines · Cong Wang
(Off-topic...)
Quoted 3 lines · Cong Wang
The code looks correct to me now, except it is suspicious
skb->lenis not updated afterskb_copy_to_linear_data()whileskb->tailis advanced already. I need to think more before submitting a patch.I feel like we need the following patch, maybe
skb->lenis updated somewhere else by "skb->tail-skb->head", otherwise we are screwed?
Maybe in skb_add_rx_frag? You might take a look at it.
Quoted 18 lines
drivers/net/ethernet/intel/igb/igb_main.c +0
-1@@ -6843,7 +6843,6 @@ static void igb_pull_tail(struct igb_ring *rx_ring,skb_frag_size_sub (frag,IGB_TS_HDR_LEN ); frag->page_offset +=IGB_TS_HDR_LEN ; skb->data_len -=IGB_TS_HDR_LEN ; - skb->len -=IGB_TS_HDR_LEN ;/* move va to start of packet data */ va +=IGB_TS_HDR_LEN ;@@ -6856,12 +6855,12 @@ static void igb_pull_tail(struct igb_ring *rx_ring,/* align pull length to size of long to optimize memcpy performance */ skb_copy_to_linear_data (skb, va,ALIGN (pull_len,sizeof (long )));
drivers/net/ethernet/intel/igb/igb_main.c static void igb_pull_tail(struct igb_ring *rx_ring, · line 6866
Quoted 10 lines
drivers/net/ethernet/intel/igb/igb_main.c +1
-1+__skb_put (skb, pull_len);/* update all of the pointers */ skb_frag_size_sub (frag, pull_len); frag->page_offset += pull_len; skb->data_len -= pull_len; - skb->tail += pull_len; }/**
Seriously? Are you even reading the code? The fragment is already a part of the skb, as such it is already included in skb->len. By re-adding the header you are adding bytes that aren't there. All we were doing is moving data from a fragment to the linear portion.
No offense but your starting to waste my time with these silly patch ideas. The patches I submitted to intel-wired-lan fix the issue that you found, and there aren't any new issues that it creates so the issue is resolved. And like I said if you need to fix this in stable just subtract IGB_TS_HDR_LEN from the header length scanned in eth_get_headlen and it will resolve the issue you reported and that way we can fix the issue and avoid pulling a fragment down to size 0.
- Alex
Quoted 10 lines · Alexander Duyck
Quoted 9 lines · Cong Wang
(Off-topic...)
Quoted 4 lines · Cong Wang
The code looks correct to me now, except it is suspicious
skb->lenis not updated afterskb_copy_to_linear_data()whileskb->tailis advanced already. I need to think more before submitting a patch.
Quoted 6 lines
Quoted 3 lines
I feel like we need the following patch, maybe
skb->lenis updated somewhere
else by "skb->tail-skb->head", otherwise we are screwed?Maybe in
skb_add_rx_frag? You might take a look at it.
I saw that.
Quoted 30 lines
Quoted 30 lines
drivers/net/ethernet/intel/igb/igb_main.c +0
-1@@ -6843,7 +6843,6 @@ static void igb_pull_tail(struct igb_ring *rx_ring,skb_frag_size_sub (frag,IGB_TS_HDR_LEN ); frag->page_offset +=IGB_TS_HDR_LEN ; skb->data_len -=IGB_TS_HDR_LEN ; - skb->len -=IGB_TS_HDR_LEN ;/* move va to start of packet data */ va +=IGB_TS_HDR_LEN ;@@ -6856,12 +6855,12 @@ static void igb_pull_tail(struct igb_ring *rx_ring,/* align pull length to size of long to optimize memcpy performance */
skb_copy_to_linear_data(skb, va, ALIGN(pull_len, sizeof(long)));drivers/net/ethernet/intel/igb/igb_main.c +1
-1+__skb_put (skb, pull_len);/* update all of the pointers */ skb_frag_size_sub (frag, pull_len); frag->page_offset += pull_len; skb->data_len -= pull_len; - skb->tail += pull_len; }
Quoted 7 lines
Quoted 1 line
/**
Seriously? Are you even reading the code? The fragment is already a part of the skb, as such it is already included in
skb->len. By re-adding the header you are adding bytes that aren't there. All we were doing is moving data from a fragment to the linear portion.
Hmm, I thought frags are counted only in skb->data_len, I misunderstood skb_headlen() and skb_pagelen().
Quoted 2 lines
No offense but your starting to waste my time with these silly patch ideas.
You can always ignore any off-topic discussion, which I already warned you in the beginning...
Quoted 7 lines
The patches I submitted to intel-wired-lan fix the issue that you found, and there aren't any new issues that it creates so the issue is resolved. And like I said if you need to fix this in stable just subtract
IGB_TS_HDR_LENfrom the header length scanned ineth_get_headlenand it will resolve the issue you reported and that way we can fix the issue and avoid pulling a fragment down to size 0.
Please keep non-off-topic discussion from off-topic ones. I will reply there.
Quoted 8 lines · Cong Wang
The second parameter of
eth_get_headlen()is the length of the frame buffer, not the header length of skb.Cc Jeff Kirsher <[email protected]>Signed-off-by Cong Wang <[email protected]>--- drivers/net/ethernet/intel/igb/igb_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Dropping this patch based on feedback from Alex.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20150424/fe67a989/attachment.asc>