: Use `unsigned' for packet lengths
PATCH 2/2 : Use `unsigned' for packet lengths
[DCCP]: Use `unsigned' for packet lengths
This patch implements a suggestion by Ian McDonald and
1) avoids tests against negative packet lengths by using unsigned (u32) for packet payload lengths in the CCID send_packet()/packet_sent() routines
2) removes an now unnecessary test with regard to `len > 0':
this condition is always true, since
* negative packet lengths are avoided
* ccid3_hc_tx_send_packet flags an error whenever the payload length is 0. As a consequence, ccid3_hc_tx_packet_sent is never called as all errors returned by ccid_hc_tx_send_packet are caught in dccp_write_xmit
--- net/dccp/ccid.h | 8 ++--- net/dccp/ccids/ccid2.c | 4 +- net/dccp/ccids/ccid3.c | 78 ++++++++++++++++++++++--------------------------- 3 files changed, 42 insertions(+), 48 deletions(-)
net/dccp/ccid.h +4 -4
@@ -52,9 +52,9 @@ struct ccid_operations { unsigned char len, u16 idx, unsigned char* value);int (*ccid_hc_tx_send_packet)(struct sock *sk, -struct sk_buff *skb,int len); +struct sk_buff *skb,u32 len);void (*ccid_hc_tx_packet_sent)(struct sock *sk,int more, -int len); +u32 len);void (*ccid_hc_rx_get_info)(struct sock *sk,struct tcp_info *info); void (*ccid_hc_tx_get_info)(struct sock *sk,
@@ -94,7 +94,7 @@ extern void ccid_hc_rx_delete(struct cciextern void ccid_hc_tx_delete (struct ccid *ccid,struct sock *sk);static inline int ccid_hc_tx_send_packet (struct ccid *ccid,struct sock *sk, -struct sk_buff *skb,int len) +struct sk_buff *skb,u32 len) {int rc =0 ;if (ccid->ccid_ops->ccid_hc_tx_send_packet !=NULL )
@@ -103,7 +103,7 @@ static inline int ccid_hc_tx_send_packet }static inline void ccid_hc_tx_packet_sent (struct ccid *ccid,struct sock *sk, -int more,int len) +int more,u32 len) {if (ccid->ccid_ops->ccid_hc_tx_packet_sent !=NULL ) ccid->ccid_ops->ccid_hc_tx_packet_sent (sk, more, len);
net/dccp/ccids/ccid2.c +2 -2
@@ -126,7 +126,7 @@ static int ccid2_hc_tx_alloc_seq(struct }static int ccid2_hc_tx_send_packet (struct sock *sk, -struct sk_buff *skb,int len) +struct sk_buff *skb,u32 len) {struct ccid2_hc_tx_sock *hctx;
@@ -268,7 +268,7 @@ static void ccid2_start_rto_timer(struct jiffies + hctx->ccid2hctx_rto); } -static void ccid2_hc_tx_packet_sent (struct sock *sk,int more,int len) +static void ccid2_hc_tx_packet_sent (struct sock *sk,int more,u32 len) {struct dccp_sock *dp =dccp_sk (sk);struct ccid2_hc_tx_sock *hctx =ccid2_hc_tx_sk (sk);
net/dccp/ccids/ccid3.c +36 -42
102 lines not on this page · raw message
Quoted 2 lines · Gerrit Renker
[DCCP]: Use `unsigned' for packet lengths
I'm wondering whether this code is 64 bit safe??? I don't think it is. Arnaldo can probably advise.
We changed int to u32 for length and I went and checked the callers and parameters. They all basically go back to skb->len which is an unsigned int. So at least we did the right thing changing to unsigned as we were mismatched before.
As much as I would like to change sk_buff definition to __u32 and save 2 bytes on 64 bit I don't think we can really as that is in a userspace include as I understand it and therefore we would break programs...
Regards,
Ian
Signature · 7 lines
Ian McDonald Web: http://wand.net.nz/~iam4 Blog: http://imcdnzl.blogspot.com WAND Network Research Group Department of Computer Science University of Waikato New Zealand
Quoting Ian McDonald:
| On 11/29/06, Gerrit Renker <[email protected]> wrote: | > [DCCP]: Use `unsigned' for packet lengths | > | I'm wondering whether this code is 64 bit safe??? I don't think it is. | Arnaldo can probably advise. | | We changed int to u32 for length and I went and checked the callers | and parameters. They all basically go back to skb->len which is an | unsigned int. So at least we did the right thing changing to unsigned | as we were mismatched before. | | As much as I would like to change sk_buff definition to __u32 and save | 2 bytes on 64 bit I don't think we can really as that is in a | userspace include as I understand it and therefore we would break | programs...
These are further changes - do you think that this would improve anything - I don't know. The proposed change of u32 for payload length seems fully sufficient in my eyes since with that we have more than enough for IPv4 and in IPv6 we are already in jumbogram-dimensions.
I have two other suggestions regarding 64-bit unsigned - I think it would make sense to store the calculated send rate in bytes per microsecond, since there are some nasty conversion problems attached to it, as well as division errors. I am working on this right now.
Quoted 4 lines · Gerrit Renker
These are further changes - do you think that this would improve anything - I don't know. The proposed change of u32 for payload length seems fully sufficient in my eyes since with that we have more than enough for IPv4 and in IPv6 we are already in jumbogram-dimensions.
I think I didn't explain my point well here. You can't change to u32 but need to be unsigned int (not u64). u32 is plenty but skb->len gets passed into the length parameter... Or that's how I read it anyway.
e.g. net/dccp/output.c dccp_write_xmit:
err = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb, skb->len);
which then goes through callback to the code in the patch.
Quoted 4 lines
I have two other suggestions regarding 64-bit unsigned - I think it would make sense to store the calculated send rate in bytes per microsecond, since there are some nasty conversion problems attached to it, as well as division errors. I am working on this right now.
Disagree if I understand you. This would imply minimum send rate of 1 million bytes per second which is often not achievable.
Regards,
Ian
Signature · 7 lines
Ian McDonald Web: http://wand.net.nz/~iam4 Blog: http://imcdnzl.blogspot.com WAND Network Research Group Department of Computer Science University of Waikato New Zealand
Quoting Ian McDonald:
| I think I didn't explain my point well here. You can't change to u32 | but need to be unsigned int (not u64).
Don't get this: u32 is a 32-bit unsigned value and therefore looks sufficient - and you are proposing `unsigned int' to have easier conversion to skb->len, right?
| u32 is plenty but skb->len gets | passed into the length parameter... Or that's how I read it anyway. | | e.g. net/dccp/output.c dccp_write_xmit: | err = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb, | skb->len); | which then goes through callback to the code in the patch.
OK, what do you suggest:
a) keep this callback interface, change len' to unsigned int'
b) keep this callback interface, patch as before (use u32)
c) change the callback interface, get rid of last argument (which is skb->len anyway) and use `unsigned int' in ccid_hc_tx_packet_sent
???
| > I have two other suggestions regarding 64-bit unsigned - I think it would make sense to store | > the calculated send rate in bytes per microsecond, since there are some nasty conversion problems | > attached to it, as well as division errors. I am working on this right now. | > | Disagree if I understand you. This would imply minimum send rate of 1 | million bytes per second which is often not achievable.
No that is not what I meant. Of course this needs to be done with regard to proper conversion - in particular, X_recv. I am at the moment trying to write this up (time consuming task), but the gist of it is - we could eliminate some problems, such as (i) having to multiply by 1E12 when computing X_calc, (ii) get better results when performing direct division. As said, will send further information.
Would really appreciate if you could at some time have a look at the moving-average patch. Have communicated with Eddie again about it, and using MSS would at the moment be much more complicated.
Quoted 6 lines · Gerrit Renker
Quoting Ian McDonald:
| I think I didn't explain my point well here. You can't change to u32 | but need to be unsigned int (not u64).Don't get this: u32 is a 32-bit unsigned value and therefore looks sufficient - and you are proposing `unsigned int' to have easier conversion to
skb->len, right?
OK. On 64 bit platform unsigned int = 64 bits and we are passing a 64 bit argument (skb->len) into a 32 bit parameter. We either need to explicitly typecast or change wherever you have put u32 to unsigned int.
Arnaldo probably knows which way is better from his experience.
Quoted 5 lines
No that is not what I meant. Of course this needs to be done with regard to proper conversion - in particular,
X_recv. I am at the moment trying to write this up (time consuming task), but the gist of it is - we could eliminate some problems, such as (i) having to multiply by 1E12 when computingX_calc, (ii) get better results when performing direct division. As said, will send further information.
OK. Will have a look at it when it arrives.
Quoted 3 lines
Would really appreciate if you could at some time have a look at the moving-average patch. Have communicated with Eddie again about it, and using MSS would at the moment be much more complicated.
Will look at it tomorrow (along with performance testing existing changes in tree) as meant to be preparing coursework and working on PhD today.... Agree MSS is problematic at present without PMTU. My thoughts were to have moving average and explicit s setting as two options available to user. If they don't set s then use moving average. I agree with Eddie that users should be able to define s if they want to.
Ian
Signature · 7 lines
Ian McDonald Web: http://wand.net.nz/~iam4 Blog: http://imcdnzl.blogspot.com WAND Network Research Group Department of Computer Science University of Waikato New Zealand
Quoted 8 lines · Ian McDonald
Quoted 7 lines · Gerrit Renker
Quoting Ian McDonald:
| I think I didn't explain my point well here. You can't change to u32 | but need to be unsigned int (not u64).Don't get this: u32 is a 32-bit unsigned value and therefore looks sufficient - and you
are proposing `unsigned int' to have easier conversion toskb->len, right?
Quoted 6 lines
OK. On 64 bit platform unsigned int = 64 bits and we are passing a 64 bit argument (
skb->len) into a 32 bit parameter. We either need to explicitly typecast or change wherever you have put u32 to unsigned int.Arnaldo probably knows which way is better from his experience.
Just make it unsigned int, matching skb->len
- Arnaldo
| On 11/29/06, Gerrit Renker <[email protected]> wrote: | > Quoting Ian McDonald: | > | I think I didn't explain my point well here. You can't change to u32 | > | but need to be unsigned int (not u64). | > Don't get this: u32 is a 32-bit unsigned value and therefore looks sufficient - and you | > are proposing `unsigned int' to have easier conversion to skb->len, right? | > | OK. On 64 bit platform unsigned int = 64 bits and we are passing a 64 | bit argument (skb->len) into a 32 bit parameter. We either need to | explicitly typecast or change wherever you have put u32 to unsigned | int. | | Arnaldo probably knows which way is better from his experience.
My suggestion then is
a) remove third arg of send_packet(), use skb->len directly
b) implement `unsigned int' as third parameter of packet_sent()
=> Arnaldo what do you think?
| > Would really appreciate if you could at some time have a look at the moving-average patch. Have communicated | > with Eddie again about it, and using MSS would at the moment be much more complicated. | > | Will look at it tomorrow (along with performance testing existing | changes in tree) as meant to be preparing coursework and working on | PhD today.... Agree MSS is problematic at present without PMTU. My | thoughts were to have moving average and explicit s setting as two | options available to user. If they don't set s then use moving | average. I agree with Eddie that users should be able to define s if | they want to.
.... but then it needs support in the API as well. The broken socket API is what really
worries me - there would be this one socket option which is only for CCID 3 and only for experimental work.
Quoted 13 lines · Gerrit Renker
| On 11/29/06, Gerrit Renker <[email protected]> wrote: | > Quoting Ian McDonald: | > | I think I didn't explain my point well here. You can't change to u32 | > | but need to be unsigned int (not u64). | > Don't get this: u32 is a 32-bit unsigned value and therefore looks sufficient - and you | > are proposing `unsigned int' to have easier conversion to skb->len, right? | > | OK. On 64 bit platform unsigned int = 64 bits and we are passing a 64 | bit argument (skb->len) into a 32 bit parameter. We either need to | explicitly typecast or change wherever you have put u32 to unsigned | int. | | Arnaldo probably knows which way is better from his experience.
Quoted 5 lines
My suggestion then is
a) remove third arg ofsend_packet(), useskb->lendirectly
b) implement `unsigned int' as third parameter ofpacket_sent()=> Arnaldo what do you think?
Checking... Agreed, send the patch please
- Arnaldo
This is a re-sent after discussion which
* changes the types to `unsigned int'
* removes the third argument of ccid_hc_tx_send_packet
since it is always set to skb->len
I double-checked this once, and compile-tested it. Gerrit
----------------> Commit Message <----------------------------------- [DCCP]: Use `unsigned' for packet lengths
This patch implements a suggestion by Ian McDonald and
1) Avoids tests against negative packet lengths by using unsigned int for packet payload lengths in the CCID send_packet()/packet_sent() routines
2) As a consequence, it removes an now unnecessary test with regard to `len > 0' in ccid3_hc_tx_packet_sent: that condition is always true, since
* negative packet lengths are avoided
* ccid3_hc_tx_send_packet flags an error whenever the payload length is 0. As a consequence, ccid3_hc_tx_packet_sent is never called as all errors returned by ccid_hc_tx_send_packet are caught in dccp_write_xmit
3) Removes the third argument of ccid_hc_tx_send_packet (the `len' parameter), since it is currently always set to skb->len. The code is updated with regard to this parameter change.
--- net/dccp/ccid.h | 14 ++++---- net/dccp/ccids/ccid2.c | 5 +- net/dccp/ccids/ccid3.c | 83 ++++++++++++++++++++++--------------------------- net/dccp/output.c | 6 +-- 4 files changed, 49 insertions(+), 59 deletions(-)
net/dccp/ccid.h +7 -7
@@ -51,10 +51,10 @@ struct ccid_operations {unsigned char option, unsigned char len, u16 idx, unsigned char* value); -int (*ccid_hc_tx_send_packet)(struct sock *sk, -struct sk_buff *skb,int len); -void (*ccid_hc_tx_packet_sent)(struct sock *sk,int more, -int len); +int (*ccid_hc_tx_send_packet)(struct sock *sk, +struct sk_buff *skb); +void (*ccid_hc_tx_packet_sent)(struct sock *sk, +int more,unsigned int len);void (*ccid_hc_rx_get_info)(struct sock *sk,struct tcp_info *info); void (*ccid_hc_tx_get_info)(struct sock *sk,
@@ -94,16 +94,16 @@ extern void ccid_hc_rx_delete(struct cciextern void ccid_hc_tx_delete (struct ccid *ccid,struct sock *sk);static inline int ccid_hc_tx_send_packet (struct ccid *ccid,struct sock *sk, -struct sk_buff *skb,int len) +struct sk_buff *skb) {int rc =0 ;if (ccid->ccid_ops->ccid_hc_tx_send_packet !=NULL ) - rc = ccid->ccid_ops->ccid_hc_tx_send_packet (sk, skb, len); + rc = ccid->ccid_ops->ccid_hc_tx_send_packet (sk, skb);return rc; }static inline void ccid_hc_tx_packet_sent (struct ccid *ccid,struct sock *sk, -int more,int len) +int more,unsigned int len) {if (ccid->ccid_ops->ccid_hc_tx_packet_sent !=NULL ) ccid->ccid_ops->ccid_hc_tx_packet_sent (sk, more, len);
net/dccp/ccids/ccid2.c +2 -3
@@ -125,8 +125,7 @@ static int ccid2_hc_tx_alloc_seq(structreturn 0 ; } -static int ccid2_hc_tx_send_packet (struct sock *sk, -struct sk_buff *skb,int len) +static int ccid2_hc_tx_send_packet (struct sock *sk,struct sk_buff *skb) {struct ccid2_hc_tx_sock *hctx;
@@ -268,7 +267,7 @@ static void ccid2_start_rto_timer(struct jiffies + hctx->ccid2hctx_rto); } -static void ccid2_hc_tx_packet_sent (struct sock *sk,int more,int len) +static void ccid2_hc_tx_packet_sent (struct sock *sk,int more,unsigned int len) {struct dccp_sock *dp =dccp_sk (sk);struct ccid2_hc_tx_sock *hctx =ccid2_hc_tx_sk (sk);
net/dccp/ccids/ccid3.c +38 -45
119 lines not on this page · raw message
net/dccp/output.c +2 -4
@@ -195,8 +195,7 @@ static int dccp_wait_for_ccid(struct socif (signal_pending (current)) goto do_interrupted; - rc =ccid_hc_tx_send_packet (dp->dccps_hc_tx_ccid, sk, skb, - skb->len); + rc =ccid_hc_tx_send_packet (dp->dccps_hc_tx_ccid, sk, skb);if (rc <=0 )break ; delay =msecs_to_jiffies (rc);
@@ -245,8 +244,7 @@ void dccp_write_xmit(struct sock *sk, inthis we have other issues */ while ((skb =skb_peek (&sk->sk_write_queue))) { -int err =ccid_hc_tx_send_packet (dp->dccps_hc_tx_ccid, sk, skb, - skb->len); +int err =ccid_hc_tx_send_packet (dp->dccps_hc_tx_ccid, sk, skb);if (err >0 ) {if (!block) {
Quoted 8 lines · Gerrit Renker
This is a re-sent after discussion which
* changes the types to `unsigned int'
* removes the third argument ofccid_hc_tx_send_packetsince it is always set to skb->lenI double-checked this once, and compile-tested it. Gerrit
Great work Gerrit. Really appreciated all this tidying up as well.
Ian
Signature · 7 lines
Ian McDonald Web: http://wand.net.nz/~iam4 Blog: http://imcdnzl.blogspot.com WAND Network Research Group Department of Computer Science University of Waikato New Zealand
Quoted 6 lines
| > Would really appreciate if you could at some time have a look at the moving-average patch. Have communicated | > with Eddie again about it, and using MSS would at the moment be much more complicated. | > | Will look at it tomorrow (along with performance testing existing | changes in tree) as meant to be preparing coursework and working on | PhD today.... Agree MSS is problematic at present without PMTU.
I guess I don't understand why using MSS is problematic for congestion control; since assuming that s=MSS causes s to drop out of all congestion control equations, returning them to packet-based CC. One could therefore set "s=ANY_ARBITRARY_VALUE" and get the same result. Ah, well! Yes, providing lots of options is harder for users than providing the one right answer, but we just don't know what that right answer is. It will be interesting to see how the moving-average patch actually behaves in practice; the Internet has much more experience with s=MSS/packet-based CC.
Eddie
Quoting Eddie Kohler:
| > | > Would really appreciate if you could at some time have a look at the moving-average patch. Have communicated | > | > with Eddie again about it, and using MSS would at the moment be much more complicated. | > | > | > | Will look at it tomorrow (along with performance testing existing | > | changes in tree) as meant to be preparing coursework and working on | > | PhD today.... Agree MSS is problematic at present without PMTU. | | I guess I don't understand why using MSS is problematic for congestion | control; since assuming that s=MSS causes s to drop out of all congestion | control equations, returning them to packet-based CC. One could therefore set | "s=ANY_ARBITRARY_VALUE" and get the same result. Ah, well! Yes, providing | lots of options is harder for users than providing the one right answer, but | we just don't know what that right answer is. It will be interesting to see | how the moving-average patch actually behaves in practice; the Internet has | much more experience with s=MSS/packet-based CC.
That would be an interesting feature to have once PMTUD is fixed (and PMTUD should also communicate expected header lengths via the CCID interface); I agree that cancelling out `s' out of the equation would, in the long run, probably make things simpler. But for the moment I'd prefer to plug all the existing holes and then return to such things.