Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 6287
b: refs/heads/master
c: 95b81ef
h: refs/heads/master
i:
  6285: 57689a9
  6283: e313c03
  6279: 1802122
  6271: 59542c6
v: v3
  • Loading branch information
Yoshifumi Nishida authored and David S. Miller committed Aug 29, 2005
1 parent fe0f94b commit b9be922
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a019d6fe2b9da68ea4ba6cf3c4e86fc1dbf554c3
refs/heads/master: 95b81ef794278c835b321f6376b0522cd5df59b7
3 changes: 2 additions & 1 deletion trunk/net/dccp/dccp.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ extern int dccp_setsockopt(struct sock *sk, int level, int optname,
char *optval, int optlen);
extern void dccp_shutdown(struct sock *sk, int how);

extern int dccp_v4_checksum(struct sk_buff *skb);
extern int dccp_v4_checksum(const struct sk_buff *skb,
const u32 saddr, const u32 daddr);

extern int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code);
extern void dccp_send_close(struct sock *sk);
Expand Down
38 changes: 20 additions & 18 deletions trunk/net/dccp/ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,9 @@ static struct sock *dccp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
return sk;
}

int dccp_v4_checksum(struct sk_buff *skb)
int dccp_v4_checksum(const struct sk_buff *skb, const u32 saddr, const u32 daddr)
{
struct dccp_hdr* dh = dccp_hdr(skb);
const struct dccp_hdr* dh = dccp_hdr(skb);
int checksum_len;
u32 tmp;

Expand All @@ -816,24 +816,24 @@ int dccp_v4_checksum(struct sk_buff *skb)
}

tmp = csum_partial((unsigned char *)dh, checksum_len, 0);
return csum_fold(tmp);
return csum_tcpudp_magic(saddr, daddr, checksum_len, IPPROTO_DCCP, tmp);
}

static int dccp_v4_verify_checksum(struct sk_buff *skb)
static int dccp_v4_verify_checksum(struct sk_buff *skb,
const u32 saddr, const u32 daddr)
{
struct dccp_hdr *th = dccp_hdr(skb);
const u16 remote_checksum = th->dccph_checksum;
u16 local_checksum;

/* FIXME: don't mess with skb payload */
th->dccph_checksum = 0; /* zero it for computation */

local_checksum = dccp_v4_checksum(skb);

/* FIXME: don't mess with skb payload */
th->dccph_checksum = remote_checksum; /* put it back */
struct dccp_hdr *dh = dccp_hdr(skb);
int checksum_len;
u32 tmp;

return remote_checksum == local_checksum ? 0 : -1;
if (dh->dccph_cscov == 0)
checksum_len = skb->len;
else {
checksum_len = (dh->dccph_cscov + dh->dccph_x) * sizeof(u32);
checksum_len = checksum_len < skb->len ? checksum_len : skb->len;
}
tmp = csum_partial((unsigned char *)dh, checksum_len, 0);
return csum_tcpudp_magic(saddr, daddr, checksum_len, IPPROTO_DCCP, tmp) == 0 ? 0 : -1;
}

static struct dst_entry* dccp_v4_route_skb(struct sock *sk,
Expand Down Expand Up @@ -902,7 +902,8 @@ void dccp_v4_ctl_send_reset(struct sk_buff *rxskb)
dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq);
dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), DCCP_SKB_CB(rxskb)->dccpd_seq);

dh->dccph_checksum = dccp_v4_checksum(skb);
dh->dccph_checksum = dccp_v4_checksum(skb, rxskb->nh.iph->saddr,
rxskb->nh.iph->daddr);

bh_lock_sock(dccp_ctl_socket->sk);
err = ip_build_and_send_pkt(skb, dccp_ctl_socket->sk,
Expand Down Expand Up @@ -1024,7 +1025,8 @@ static inline int dccp_invalid_packet(struct sk_buff *skb)
}

/* If the header checksum is incorrect, drop packet and return */
if (dccp_v4_verify_checksum(skb) < 0) {
if (dccp_v4_verify_checksum(skb, skb->nh.iph->saddr,
skb->nh.iph->daddr) < 0) {
dccp_pr_debug("header checksum is incorrect\n");
return 1;
}
Expand Down
9 changes: 6 additions & 3 deletions trunk/net/dccp/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
break;
}

dh->dccph_checksum = dccp_v4_checksum(skb);
dh->dccph_checksum = dccp_v4_checksum(skb, inet->saddr,
inet->daddr);

if (dcb->dccpd_type == DCCP_PKT_ACK ||
dcb->dccpd_type == DCCP_PKT_DATAACK)
Expand Down Expand Up @@ -193,7 +194,8 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
dccp_hdr_set_seq(dh, dccp_rsk(req)->dreq_iss);
dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dccp_rsk(req)->dreq_isr);

dh->dccph_checksum = dccp_v4_checksum(skb);
dh->dccph_checksum = dccp_v4_checksum(skb, inet_rsk(req)->loc_addr,
inet_rsk(req)->rmt_addr);

DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
return skb;
Expand Down Expand Up @@ -242,7 +244,8 @@ struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst,

dccp_hdr_reset(skb)->dccph_reset_code = code;

dh->dccph_checksum = dccp_v4_checksum(skb);
dh->dccph_checksum = dccp_v4_checksum(skb, inet_sk(sk)->saddr,
inet_sk(sk)->daddr);

DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
return skb;
Expand Down

0 comments on commit b9be922

Please sign in to comment.