DCCP protocol discussions
 help / color / mirror / Atom feed
* [PATCH 1/5]: Shorten variable names in dccp_check_seqno
@ 2007-06-20  9:55 Gerrit Renker
  0 siblings, 0 replies; 3+ messages in thread
From: Gerrit Renker @ 2007-06-20  9:55 UTC (permalink / raw)
  To: dccp

[DCCP]: Shorten variable names in dccp_check_seqno

This patch is in part required by the next patch; it

 * replaces 6 instances of `DCCP_SKB_CB(skb)->dccpd_seq' with `seqno';
 * replaces 7 instances of `DCCP_SKB_CB(skb)->dccpd_ack_seq' with `ackno';
 * replaces 1 use of dccp_inc_seqno() by unfolding `ADD48' macro in place.

No changes in algorithm, all changes are text replacement/substitution.

Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> 
---
 net/dccp/input.c |   40 +++++++++++++++++-----------------------
 1 file changed, 17 insertions(+), 23 deletions(-)

--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -68,7 +68,8 @@ static int dccp_check_seqno(struct sock 
 {
 	const struct dccp_hdr *dh = dccp_hdr(skb);
 	struct dccp_sock *dp = dccp_sk(sk);
-	u64 lswl, lawl;
+	u64 lswl, lawl, seqno = DCCP_SKB_CB(skb)->dccpd_seq,
+			ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
 
 	/*
 	 *   Step 5: Prepare sequence numbers for Sync
@@ -84,11 +85,9 @@ static int dccp_check_seqno(struct sock 
 	 */
 	if (dh->dccph_type = DCCP_PKT_SYNC ||
 	    dh->dccph_type = DCCP_PKT_SYNCACK) {
-		if (between48(DCCP_SKB_CB(skb)->dccpd_ack_seq,
-			      dp->dccps_awl, dp->dccps_awh) &&
-		    dccp_delta_seqno(dp->dccps_swl,
-				     DCCP_SKB_CB(skb)->dccpd_seq) >= 0)
-			dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq);
+		if (between48(ackno, dp->dccps_awl, dp->dccps_awh) &&
+		    dccp_delta_seqno(dp->dccps_swl, seqno) >= 0)
+			dccp_update_gsr(sk, seqno);
 		else
 			return -1;
 	}
@@ -113,35 +112,30 @@ static int dccp_check_seqno(struct sock 
 	if (dh->dccph_type = DCCP_PKT_CLOSEREQ ||
 	    dh->dccph_type = DCCP_PKT_CLOSE ||
 	    dh->dccph_type = DCCP_PKT_RESET) {
-		lswl = dp->dccps_gsr;
-		dccp_inc_seqno(&lswl);
+		lswl = ADD48(dp->dccps_gsr, 1);
 		lawl = dp->dccps_gar;
 	}
 
-	if (between48(DCCP_SKB_CB(skb)->dccpd_seq, lswl, dp->dccps_swh) &&
-	    (DCCP_SKB_CB(skb)->dccpd_ack_seq = DCCP_PKT_WITHOUT_ACK_SEQ ||
-	     between48(DCCP_SKB_CB(skb)->dccpd_ack_seq,
-		       lawl, dp->dccps_awh))) {
-		dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq);
+	if (between48(seqno, lswl, dp->dccps_swh) &&
+	    (ackno = DCCP_PKT_WITHOUT_ACK_SEQ ||
+	     between48(ackno, lawl, dp->dccps_awh))) {
+		dccp_update_gsr(sk, seqno);
 
 		if (dh->dccph_type != DCCP_PKT_SYNC &&
-		    (DCCP_SKB_CB(skb)->dccpd_ack_seq !-		     DCCP_PKT_WITHOUT_ACK_SEQ))
-			dp->dccps_gar = DCCP_SKB_CB(skb)->dccpd_ack_seq;
+		    (ackno != DCCP_PKT_WITHOUT_ACK_SEQ))
+			dp->dccps_gar = ackno;
 	} else {
 		DCCP_WARN("DCCP: Step 6 failed for %s packet, "
 			  "(LSWL(%llu) <= P.seqno(%llu) <= S.SWH(%llu)) and "
 			  "(P.ackno %s or LAWL(%llu) <= P.ackno(%llu) <= S.AWH(%llu), "
 			  "sending SYNC...\n",  dccp_packet_name(dh->dccph_type),
-			  (unsigned long long) lswl,
-			  (unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq,
+			  (unsigned long long) lswl, (unsigned long long) seqno,
 			  (unsigned long long) dp->dccps_swh,
-			  (DCCP_SKB_CB(skb)->dccpd_ack_seq =
-				DCCP_PKT_WITHOUT_ACK_SEQ) ? "doesn't exist" : "exists",
-			  (unsigned long long) lawl,
-			  (unsigned long long) DCCP_SKB_CB(skb)->dccpd_ack_seq,
+			  (ackno = DCCP_PKT_WITHOUT_ACK_SEQ) ? "doesn't exist"
+							      : "exists",
+			  (unsigned long long) lawl, (unsigned long long) ackno,
 			  (unsigned long long) dp->dccps_awh);
-		dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq, DCCP_PKT_SYNC);
+		dccp_send_sync(sk, seqno, DCCP_PKT_SYNC);
 		return -1;
 	}
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/5]: Shorten variable names in dccp_check_seqno
@ 2007-07-01  3:54 Ian McDonald
  0 siblings, 0 replies; 3+ messages in thread
From: Ian McDonald @ 2007-07-01  3:54 UTC (permalink / raw)
  To: dccp

On 6/20/07, Gerrit Renker <gerrit@erg.abdn.ac.uk> wrote:
> [DCCP]: Shorten variable names in dccp_check_seqno
>
> This patch is in part required by the next patch; it
>
>  * replaces 6 instances of `DCCP_SKB_CB(skb)->dccpd_seq' with `seqno';
>  * replaces 7 instances of `DCCP_SKB_CB(skb)->dccpd_ack_seq' with `ackno';
>  * replaces 1 use of dccp_inc_seqno() by unfolding `ADD48' macro in place.
>
> No changes in algorithm, all changes are text replacement/substitution.
>
> Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
> ---
>  net/dccp/input.c |   40 +++++++++++++++++-----------------------
>  1 file changed, 17 insertions(+), 23 deletions(-)
>
> --- a/net/dccp/input.c
> +++ b/net/dccp/input.c
> @@ -68,7 +68,8 @@ static int dccp_check_seqno(struct sock
>  {
>         const struct dccp_hdr *dh = dccp_hdr(skb);
>         struct dccp_sock *dp = dccp_sk(sk);
> -       u64 lswl, lawl;
> +       u64 lswl, lawl, seqno = DCCP_SKB_CB(skb)->dccpd_seq,
> +                       ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
>
I think this would be better served by a macro e.g.
#define SEQNO DCCP_SKB_CB(skb)->dccpd_seq

With the change you're making here you're increasing stack usage by 16 bytes.

Ian
-- 
Web: http://wand.net.nz/~iam4/
Blog: http://iansblog.jandi.co.nz
WAND Network Research Group

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/5]: Shorten variable names in dccp_check_seqno
@ 2007-09-22 19:31 Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2007-09-22 19:31 UTC (permalink / raw)
  To: dccp

Em Sun, Jul 01, 2007 at 03:54:12PM +1200, Ian McDonald escreveu:
> On 6/20/07, Gerrit Renker <gerrit@erg.abdn.ac.uk> wrote:
>> [DCCP]: Shorten variable names in dccp_check_seqno
>>
>> This patch is in part required by the next patch; it
>>
>>  * replaces 6 instances of `DCCP_SKB_CB(skb)->dccpd_seq' with `seqno';
>>  * replaces 7 instances of `DCCP_SKB_CB(skb)->dccpd_ack_seq' with `ackno';
>>  * replaces 1 use of dccp_inc_seqno() by unfolding `ADD48' macro in place.
>>
>> No changes in algorithm, all changes are text replacement/substitution.
>>
>> Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
>> ---
>>  net/dccp/input.c |   40 +++++++++++++++++-----------------------
>>  1 file changed, 17 insertions(+), 23 deletions(-)
>>
>> --- a/net/dccp/input.c
>> +++ b/net/dccp/input.c
>> @@ -68,7 +68,8 @@ static int dccp_check_seqno(struct sock
>>  {
>>         const struct dccp_hdr *dh = dccp_hdr(skb);
>>         struct dccp_sock *dp = dccp_sk(sk);
>> -       u64 lswl, lawl;
>> +       u64 lswl, lawl, seqno = DCCP_SKB_CB(skb)->dccpd_seq,
>> +                       ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
>>
> I think this would be better served by a macro e.g.
> #define SEQNO DCCP_SKB_CB(skb)->dccpd_seq
>
> With the change you're making here you're increasing stack usage by 16 
> bytes.

But at least in another metric we gain back some bytes, the number of
inline expansions is reduced and with that the binary size is shrunk by
65 bytes on 32 bit arches:

[acme@filo net-2.6.24]$ codiff -V /tmp/input.o.before ../build/net-2.6.24/t/net/dccp/input.o
/home/acme/git/net-2.6.24/net/dccp/input.c:
  dccp_check_seqno |  -65 # 1132 -> 1067, # inlines: 7 -> 6, size inlines: 396 -> 360
   1 function changed, 65 bytes removed

Humm, codiff should show changes on variables... /me adds it to the TODO
list :-)

- Arnaldo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-09-22 19:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-22 19:31 [PATCH 1/5]: Shorten variable names in dccp_check_seqno Arnaldo Carvalho de Melo
  -- strict thread matches above, loose matches on Subject: below --
2007-07-01  3:54 Ian McDonald
2007-06-20  9:55 Gerrit Renker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox