diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2006-11-13 10:34:38 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-03 00:22:22 -0500 |
commit | d7f7365f5776723da6df73540d855069c2daaa5c (patch) | |
tree | cc63c8a85c4d6a768cee8da00577900215e786a8 | |
parent | 865e9022d88ceedd89fa1079a6e1f9266ccd3711 (diff) |
[DCCPv6]: Choose a genuine initial sequence number
This
* resolves a FIXME - DCCPv6 connections started all with
an initial sequence number of 1;
* provides a redirection `secure_dccpv6_sequence_number'
in case the init_sequence_v6 code should be updated later;
* concentrates the update of S.GAR into dccp_connect_init();
* removes a duplicate dccp_update_gss() in ipv4.c;
* uses inet->dport instead of usin->sin_port, due to the
following assignment in dccp_v4_connect():
inet->dport = usin->sin_port;
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
-rw-r--r-- | net/dccp/ipv4.c | 9 | ||||
-rw-r--r-- | net/dccp/ipv6.c | 28 | ||||
-rw-r--r-- | net/dccp/output.c | 6 |
3 files changed, 23 insertions, 20 deletions
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index b56a2fa2694a..bc400b2ba25e 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -113,13 +113,8 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
113 | /* OK, now commit destination to socket. */ | 113 | /* OK, now commit destination to socket. */ |
114 | sk_setup_caps(sk, &rt->u.dst); | 114 | sk_setup_caps(sk, &rt->u.dst); |
115 | 115 | ||
116 | dp->dccps_gar = | 116 | dp->dccps_iss = secure_dccp_sequence_number(inet->saddr, inet->daddr, |
117 | dp->dccps_iss = secure_dccp_sequence_number(inet->saddr, | 117 | inet->sport, inet->dport); |
118 | inet->daddr, | ||
119 | inet->sport, | ||
120 | usin->sin_port); | ||
121 | dccp_update_gss(sk, dp->dccps_iss); | ||
122 | |||
123 | inet->id = dp->dccps_iss ^ jiffies; | 118 | inet->id = dp->dccps_iss ^ jiffies; |
124 | 119 | ||
125 | err = dccp_connect(sk); | 120 | err = dccp_connect(sk); |
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index a08af75ddc9e..8d6ddb6389a7 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
@@ -76,12 +76,19 @@ static inline void dccp_v6_send_check(struct sock *sk, int unused_value, | |||
76 | dh->dccph_checksum = dccp_v6_csum_finish(skb, &np->saddr, &np->daddr); | 76 | dh->dccph_checksum = dccp_v6_csum_finish(skb, &np->saddr, &np->daddr); |
77 | } | 77 | } |
78 | 78 | ||
79 | static inline __u32 dccp_v6_init_sequence(const struct sk_buff *skb) | 79 | static inline __u32 secure_dccpv6_sequence_number(__u32 *saddr, __u32 *daddr, |
80 | __u16 sport, __u16 dport ) | ||
80 | { | 81 | { |
81 | return secure_tcpv6_sequence_number(skb->nh.ipv6h->daddr.s6_addr32, | 82 | return secure_tcpv6_sequence_number(saddr, daddr, sport, dport); |
82 | skb->nh.ipv6h->saddr.s6_addr32, | 83 | } |
83 | dccp_hdr(skb)->dccph_dport, | 84 | |
84 | dccp_hdr(skb)->dccph_sport ); | 85 | static inline __u32 dccp_v6_init_sequence(struct sk_buff *skb) |
86 | { | ||
87 | return secure_dccpv6_sequence_number(skb->nh.ipv6h->daddr.s6_addr32, | ||
88 | skb->nh.ipv6h->saddr.s6_addr32, | ||
89 | dccp_hdr(skb)->dccph_dport, | ||
90 | dccp_hdr(skb)->dccph_sport ); | ||
91 | |||
85 | } | 92 | } |
86 | 93 | ||
87 | static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | 94 | static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, |
@@ -1065,13 +1072,10 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, | |||
1065 | err = inet6_hash_connect(&dccp_death_row, sk); | 1072 | err = inet6_hash_connect(&dccp_death_row, sk); |
1066 | if (err) | 1073 | if (err) |
1067 | goto late_failure; | 1074 | goto late_failure; |
1068 | /* FIXME */ | 1075 | |
1069 | #if 0 | 1076 | dp->dccps_iss = secure_dccpv6_sequence_number(np->saddr.s6_addr32, |
1070 | dp->dccps_gar = secure_dccp_v6_sequence_number(np->saddr.s6_addr32, | 1077 | np->daddr.s6_addr32, |
1071 | np->daddr.s6_addr32, | 1078 | inet->sport, inet->dport); |
1072 | inet->sport, | ||
1073 | inet->dport); | ||
1074 | #endif | ||
1075 | err = dccp_connect(sk); | 1079 | err = dccp_connect(sk); |
1076 | if (err) | 1080 | if (err) |
1077 | goto late_failure; | 1081 | goto late_failure; |
diff --git a/net/dccp/output.c b/net/dccp/output.c index 08ee5547a2f2..0994b13f0f15 100644 --- a/net/dccp/output.c +++ b/net/dccp/output.c | |||
@@ -448,7 +448,6 @@ static inline void dccp_connect_init(struct sock *sk) | |||
448 | 448 | ||
449 | dccp_sync_mss(sk, dst_mtu(dst)); | 449 | dccp_sync_mss(sk, dst_mtu(dst)); |
450 | 450 | ||
451 | dccp_update_gss(sk, dp->dccps_iss); | ||
452 | /* | 451 | /* |
453 | * SWL and AWL are initially adjusted so that they are not less than | 452 | * SWL and AWL are initially adjusted so that they are not less than |
454 | * the initial Sequence Numbers received and sent, respectively: | 453 | * the initial Sequence Numbers received and sent, respectively: |
@@ -457,8 +456,13 @@ static inline void dccp_connect_init(struct sock *sk) | |||
457 | * These adjustments MUST be applied only at the beginning of the | 456 | * These adjustments MUST be applied only at the beginning of the |
458 | * connection. | 457 | * connection. |
459 | */ | 458 | */ |
459 | dccp_update_gss(sk, dp->dccps_iss); | ||
460 | dccp_set_seqno(&dp->dccps_awl, max48(dp->dccps_awl, dp->dccps_iss)); | 460 | dccp_set_seqno(&dp->dccps_awl, max48(dp->dccps_awl, dp->dccps_iss)); |
461 | 461 | ||
462 | /* S.GAR - greatest valid acknowledgement number received on a non-Sync; | ||
463 | * initialized to S.ISS (sec. 8.5) */ | ||
464 | dp->dccps_gar = dp->dccps_iss; | ||
465 | |||
462 | icsk->icsk_retransmits = 0; | 466 | icsk->icsk_retransmits = 0; |
463 | init_timer(&dp->dccps_xmit_timer); | 467 | init_timer(&dp->dccps_xmit_timer); |
464 | dp->dccps_xmit_timer.data = (unsigned long)sk; | 468 | dp->dccps_xmit_timer.data = (unsigned long)sk; |