Skip to content

Commit 8c56a34

Browse files
author
David S. Miller
committed
Merge master.kernel.org:/pub/scm/linux/kernel/git/acme/net-2.6
2 parents d892afe + 24c667d commit 8c56a34

7 files changed

Lines changed: 79 additions & 43 deletions

File tree

‎include/linux/dccp.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ enum dccp_reset_codes {
144144
DCCP_RESET_CODE_TOO_BUSY,
145145
DCCP_RESET_CODE_BAD_INIT_COOKIE,
146146
DCCP_RESET_CODE_AGGRESSION_PENALTY,
147+
148+
DCCP_MAX_RESET_CODES /* Leave at the end! */
147149
};
148150

149151
/* DCCP options */
@@ -270,10 +272,9 @@ static inline struct dccp_hdr *dccp_zeroed_hdr(struct sk_buff *skb, int headlen)
270272
return memset(skb_transport_header(skb), 0, headlen);
271273
}
272274

273-
static inline struct dccp_hdr_ext *dccp_hdrx(const struct sk_buff *skb)
275+
static inline struct dccp_hdr_ext *dccp_hdrx(const struct dccp_hdr *dh)
274276
{
275-
return (struct dccp_hdr_ext *)(skb_transport_header(skb) +
276-
sizeof(struct dccp_hdr));
277+
return (struct dccp_hdr_ext *)((unsigned char *)dh + sizeof(*dh));
277278
}
278279

279280
static inline unsigned int __dccp_basic_hdr_len(const struct dccp_hdr *dh)
@@ -287,13 +288,12 @@ static inline unsigned int dccp_basic_hdr_len(const struct sk_buff *skb)
287288
return __dccp_basic_hdr_len(dh);
288289
}
289290

290-
static inline __u64 dccp_hdr_seq(const struct sk_buff *skb)
291+
static inline __u64 dccp_hdr_seq(const struct dccp_hdr *dh)
291292
{
292-
const struct dccp_hdr *dh = dccp_hdr(skb);
293293
__u64 seq_nr = ntohs(dh->dccph_seq);
294294

295295
if (dh->dccph_x != 0)
296-
seq_nr = (seq_nr << 32) + ntohl(dccp_hdrx(skb)->dccph_seq_low);
296+
seq_nr = (seq_nr << 32) + ntohl(dccp_hdrx(dh)->dccph_seq_low);
297297
else
298298
seq_nr += (u32)dh->dccph_seq2 << 16;
299299

‎net/dccp/ccids/ccid2.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,20 +750,16 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
750750
*/
751751
hctx->ccid2hctx_ssthresh = ~0;
752752
hctx->ccid2hctx_numdupack = 3;
753-
hctx->ccid2hctx_seqbufc = 0;
754753

755754
/* XXX init ~ to window size... */
756755
if (ccid2_hc_tx_alloc_seq(hctx))
757756
return -ENOMEM;
758757

759-
hctx->ccid2hctx_sent = 0;
760758
hctx->ccid2hctx_rto = 3 * HZ;
761759
ccid2_change_srtt(hctx, -1);
762760
hctx->ccid2hctx_rttvar = -1;
763-
hctx->ccid2hctx_lastrtt = 0;
764761
hctx->ccid2hctx_rpdupack = -1;
765762
hctx->ccid2hctx_last_cong = jiffies;
766-
hctx->ccid2hctx_high_ack = 0;
767763

768764
hctx->ccid2hctx_rtotimer.function = &ccid2_hc_tx_rto_expire;
769765
hctx->ccid2hctx_rtotimer.data = (unsigned long)sk;

‎net/dccp/ccids/ccid3.c‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
#include "lib/tfrc.h"
4141
#include "ccid3.h"
4242

43+
#include <asm/unaligned.h>
44+
4345
#ifdef CONFIG_IP_DCCP_CCID3_DEBUG
4446
static int ccid3_debug;
4547
#define ccid3_pr_debug(format, a...) DCCP_PR_DEBUG(ccid3_debug, format, ##a)
@@ -544,6 +546,7 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
544546
const struct dccp_sock *dp = dccp_sk(sk);
545547
struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
546548
struct ccid3_options_received *opt_recv;
549+
__be32 opt_val;
547550

548551
opt_recv = &hctx->ccid3hctx_options_received;
549552

@@ -563,8 +566,8 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
563566
dccp_role(sk), sk, len);
564567
rc = -EINVAL;
565568
} else {
566-
opt_recv->ccid3or_loss_event_rate =
567-
ntohl(*(__be32 *)value);
569+
opt_val = get_unaligned((__be32 *)value);
570+
opt_recv->ccid3or_loss_event_rate = ntohl(opt_val);
568571
ccid3_pr_debug("%s(%p), LOSS_EVENT_RATE=%u\n",
569572
dccp_role(sk), sk,
570573
opt_recv->ccid3or_loss_event_rate);
@@ -585,8 +588,8 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
585588
dccp_role(sk), sk, len);
586589
rc = -EINVAL;
587590
} else {
588-
opt_recv->ccid3or_receive_rate =
589-
ntohl(*(__be32 *)value);
591+
opt_val = get_unaligned((__be32 *)value);
592+
opt_recv->ccid3or_receive_rate = ntohl(opt_val);
590593
ccid3_pr_debug("%s(%p), RECEIVE_RATE=%u\n",
591594
dccp_role(sk), sk,
592595
opt_recv->ccid3or_receive_rate);
@@ -601,8 +604,6 @@ static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk)
601604
{
602605
struct ccid3_hc_tx_sock *hctx = ccid_priv(ccid);
603606

604-
hctx->ccid3hctx_s = 0;
605-
hctx->ccid3hctx_rtt = 0;
606607
hctx->ccid3hctx_state = TFRC_SSTATE_NO_SENT;
607608
INIT_LIST_HEAD(&hctx->ccid3hctx_hist);
608609

@@ -963,8 +964,6 @@ static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk)
963964
INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist);
964965
hcrx->ccid3hcrx_tstamp_last_feedback =
965966
hcrx->ccid3hcrx_tstamp_last_ack = ktime_get_real();
966-
hcrx->ccid3hcrx_s = 0;
967-
hcrx->ccid3hcrx_rtt = 0;
968967
return 0;
969968
}
970969

‎net/dccp/input.c‎

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,42 @@ static void dccp_rcv_closereq(struct sock *sk, struct sk_buff *skb)
5858
dccp_send_close(sk, 0);
5959
}
6060

61+
static u8 dccp_reset_code_convert(const u8 code)
62+
{
63+
const u8 error_code[] = {
64+
[DCCP_RESET_CODE_CLOSED] = 0, /* normal termination */
65+
[DCCP_RESET_CODE_UNSPECIFIED] = 0, /* nothing known */
66+
[DCCP_RESET_CODE_ABORTED] = ECONNRESET,
67+
68+
[DCCP_RESET_CODE_NO_CONNECTION] = ECONNREFUSED,
69+
[DCCP_RESET_CODE_CONNECTION_REFUSED] = ECONNREFUSED,
70+
[DCCP_RESET_CODE_TOO_BUSY] = EUSERS,
71+
[DCCP_RESET_CODE_AGGRESSION_PENALTY] = EDQUOT,
72+
73+
[DCCP_RESET_CODE_PACKET_ERROR] = ENOMSG,
74+
[DCCP_RESET_CODE_BAD_INIT_COOKIE] = EBADR,
75+
[DCCP_RESET_CODE_BAD_SERVICE_CODE] = EBADRQC,
76+
[DCCP_RESET_CODE_OPTION_ERROR] = EILSEQ,
77+
[DCCP_RESET_CODE_MANDATORY_ERROR] = EOPNOTSUPP,
78+
};
79+
80+
return code >= DCCP_MAX_RESET_CODES ? 0 : error_code[code];
81+
}
82+
83+
static void dccp_rcv_reset(struct sock *sk, struct sk_buff *skb)
84+
{
85+
u8 err = dccp_reset_code_convert(dccp_hdr_reset(skb)->dccph_reset_code);
86+
87+
sk->sk_err = err;
88+
89+
/* Queue the equivalent of TCP fin so that dccp_recvmsg exits the loop */
90+
dccp_fin(sk, skb);
91+
92+
if (err && !sock_flag(sk, SOCK_DEAD))
93+
sk_wake_async(sk, 0, POLL_ERR);
94+
dccp_time_wait(sk, DCCP_TIME_WAIT, 0);
95+
}
96+
6197
static void dccp_event_ack_recv(struct sock *sk, struct sk_buff *skb)
6298
{
6399
struct dccp_sock *dp = dccp_sk(sk);
@@ -191,9 +227,8 @@ static int __dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
191227
* S.state := TIMEWAIT
192228
* Set TIMEWAIT timer
193229
* Drop packet and return
194-
*/
195-
dccp_fin(sk, skb);
196-
dccp_time_wait(sk, DCCP_TIME_WAIT, 0);
230+
*/
231+
dccp_rcv_reset(sk, skb);
197232
return 0;
198233
case DCCP_PKT_CLOSEREQ:
199234
dccp_rcv_closereq(sk, skb);
@@ -521,12 +556,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
521556
* Drop packet and return
522557
*/
523558
if (dh->dccph_type == DCCP_PKT_RESET) {
524-
/*
525-
* Queue the equivalent of TCP fin so that dccp_recvmsg
526-
* exits the loop
527-
*/
528-
dccp_fin(sk, skb);
529-
dccp_time_wait(sk, DCCP_TIME_WAIT, 0);
559+
dccp_rcv_reset(sk, skb);
530560
return 0;
531561
/*
532562
* Step 7: Check for unexpected packet types

‎net/dccp/ipv4.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)
241241
goto out;
242242

243243
dp = dccp_sk(sk);
244-
seq = dccp_hdr_seq(skb);
245-
if (sk->sk_state != DCCP_LISTEN &&
244+
seq = dccp_hdr_seq(dh);
245+
if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_LISTEN) &&
246246
!between48(seq, dp->dccps_swl, dp->dccps_swh)) {
247247
NET_INC_STATS_BH(LINUX_MIB_OUTOFWINDOWICMPS);
248248
goto out;
@@ -795,7 +795,7 @@ static int dccp_v4_rcv(struct sk_buff *skb)
795795

796796
dh = dccp_hdr(skb);
797797

798-
DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(skb);
798+
DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh);
799799
DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type;
800800

801801
dccp_pr_debug("%8.8s "

‎net/dccp/ipv6.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
173173

174174
icmpv6_err_convert(type, code, &err);
175175

176-
seq = DCCP_SKB_CB(skb)->dccpd_seq;
176+
seq = dccp_hdr_seq(dh);
177177
/* Might be for an request_sock */
178178
switch (sk->sk_state) {
179179
struct request_sock *req, **prev;
@@ -787,7 +787,7 @@ static int dccp_v6_rcv(struct sk_buff *skb)
787787

788788
dh = dccp_hdr(skb);
789789

790-
DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(skb);
790+
DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh);
791791
DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type;
792792

793793
if (dccp_packet_without_ack(skb))

‎net/dccp/options.c‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/dccp.h>
1515
#include <linux/module.h>
1616
#include <linux/types.h>
17+
#include <asm/unaligned.h>
1718
#include <linux/kernel.h>
1819
#include <linux/skbuff.h>
1920

@@ -59,6 +60,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
5960
unsigned char opt, len;
6061
unsigned char *value;
6162
u32 elapsed_time;
63+
__be32 opt_val;
6264
int rc;
6365
int mandatory = 0;
6466

@@ -145,7 +147,8 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
145147
if (len != 4)
146148
goto out_invalid_option;
147149

148-
opt_recv->dccpor_timestamp = ntohl(*(__be32 *)value);
150+
opt_val = get_unaligned((__be32 *)value);
151+
opt_recv->dccpor_timestamp = ntohl(opt_val);
149152

150153
dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp;
151154
dp->dccps_timestamp_time = ktime_get_real();
@@ -159,7 +162,8 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
159162
if (len != 4 && len != 6 && len != 8)
160163
goto out_invalid_option;
161164

162-
opt_recv->dccpor_timestamp_echo = ntohl(*(__be32 *)value);
165+
opt_val = get_unaligned((__be32 *)value);
166+
opt_recv->dccpor_timestamp_echo = ntohl(opt_val);
163167

164168
dccp_pr_debug("%s rx opt: TIMESTAMP_ECHO=%u, len=%d, "
165169
"ackno=%llu", dccp_role(sk),
@@ -168,16 +172,20 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
168172
(unsigned long long)
169173
DCCP_SKB_CB(skb)->dccpd_ack_seq);
170174

175+
value += 4;
171176

172-
if (len == 4) {
177+
if (len == 4) { /* no elapsed time included */
173178
dccp_pr_debug_cat("\n");
174179
break;
175180
}
176181

177-
if (len == 6)
178-
elapsed_time = ntohs(*(__be16 *)(value + 4));
179-
else
180-
elapsed_time = ntohl(*(__be32 *)(value + 4));
182+
if (len == 6) { /* 2-byte elapsed time */
183+
__be16 opt_val2 = get_unaligned((__be16 *)value);
184+
elapsed_time = ntohs(opt_val2);
185+
} else { /* 4-byte elapsed time */
186+
opt_val = get_unaligned((__be32 *)value);
187+
elapsed_time = ntohl(opt_val);
188+
}
181189

182190
dccp_pr_debug_cat(", ELAPSED_TIME=%u\n", elapsed_time);
183191

@@ -192,10 +200,13 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
192200
if (pkt_type == DCCP_PKT_DATA)
193201
continue;
194202

195-
if (len == 2)
196-
elapsed_time = ntohs(*(__be16 *)value);
197-
else
198-
elapsed_time = ntohl(*(__be32 *)value);
203+
if (len == 2) {
204+
__be16 opt_val2 = get_unaligned((__be16 *)value);
205+
elapsed_time = ntohs(opt_val2);
206+
} else {
207+
opt_val = get_unaligned((__be32 *)value);
208+
elapsed_time = ntohl(opt_val);
209+
}
199210

200211
if (elapsed_time > opt_recv->dccpor_elapsed_time)
201212
opt_recv->dccpor_elapsed_time = elapsed_time;

0 commit comments

Comments
 (0)