Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
276829d1
Commit
276829d1
authored
Apr 09, 2003
by
Jon Grimm
Committed by
Sridhar Samudrala
Apr 09, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SCTP] Add a generic csum_copy for sctp.
Do the sctp checksum while copying.
parent
845401fc
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
61 deletions
+95
-61
include/net/sctp/sctp.h
include/net/sctp/sctp.h
+1
-0
net/sctp/adler32.c
net/sctp/adler32.c
+27
-18
net/sctp/crc32c.c
net/sctp/crc32c.c
+17
-0
net/sctp/output.c
net/sctp/output.c
+50
-43
No files found.
include/net/sctp/sctp.h
View file @
276829d1
...
@@ -153,6 +153,7 @@ extern int sctp_primitive_REQUESTHEARTBEAT(struct sctp_association *, void *arg)
...
@@ -153,6 +153,7 @@ extern int sctp_primitive_REQUESTHEARTBEAT(struct sctp_association *, void *arg)
extern
__u32
sctp_start_cksum
(
__u8
*
ptr
,
__u16
count
);
extern
__u32
sctp_start_cksum
(
__u8
*
ptr
,
__u16
count
);
extern
__u32
sctp_update_cksum
(
__u8
*
ptr
,
__u16
count
,
__u32
cksum
);
extern
__u32
sctp_update_cksum
(
__u8
*
ptr
,
__u16
count
,
__u32
cksum
);
extern
__u32
sctp_end_cksum
(
__u32
cksum
);
extern
__u32
sctp_end_cksum
(
__u32
cksum
);
extern
__u32
sctp_update_copy_cksum
(
__u8
*
,
__u8
*
,
__u16
count
,
__u32
cksum
);
/*
/*
* sctp/input.c
* sctp/input.c
...
...
net/sctp/adler32.c
View file @
276829d1
...
@@ -156,6 +156,15 @@ __u32 sctp_update_cksum(__u8 *ptr, __u16 count, __u32 adler)
...
@@ -156,6 +156,15 @@ __u32 sctp_update_cksum(__u8 *ptr, __u16 count, __u32 adler)
return
adler
;
return
adler
;
}
}
__u32
sctp_update_copy_cksum
(
__u8
*
to
,
__u8
*
from
,
__u16
count
,
__u32
adler
)
{
/* Its not worth it to try harder. Adler32 is obsolescent. */
adler
=
update_adler32
(
adler
,
from
,
count
);
memcpy
(
to
,
from
,
count
);
return
adler
;
}
__u32
sctp_end_cksum
(
__u32
adler
)
__u32
sctp_end_cksum
(
__u32
adler
)
{
{
return
adler
;
return
adler
;
...
...
net/sctp/crc32c.c
View file @
276829d1
...
@@ -170,6 +170,23 @@ __u32 sctp_update_cksum(__u8 *buffer, __u16 length, __u32 crc32)
...
@@ -170,6 +170,23 @@ __u32 sctp_update_cksum(__u8 *buffer, __u16 length, __u32 crc32)
return
crc32
;
return
crc32
;
}
}
__u32
sctp_update_copy_cksum
(
__u8
*
to
,
__u8
*
from
,
__u16
length
,
__u32
crc32
)
{
__u32
i
;
__u32
*
_to
=
(
__u32
*
)
to
;
__u32
*
_from
=
(
__u32
*
)
from
;
for
(
i
=
0
;
i
<
(
length
/
4
);
i
++
)
{
_to
[
i
]
=
_from
[
i
];
CRC32C
(
crc32
,
from
[
i
*
4
]);
CRC32C
(
crc32
,
from
[
i
*
4
+
1
]);
CRC32C
(
crc32
,
from
[
i
*
4
+
2
]);
CRC32C
(
crc32
,
from
[
i
*
4
+
3
]);
}
return
crc32
;
}
__u32
sctp_end_cksum
(
__u32
crc32
)
__u32
sctp_end_cksum
(
__u32
crc32
)
{
{
__u32
result
;
__u32
result
;
...
...
net/sctp/output.c
View file @
276829d1
...
@@ -276,8 +276,8 @@ sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet,
...
@@ -276,8 +276,8 @@ sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet,
*/
*/
int
sctp_packet_transmit
(
struct
sctp_packet
*
packet
)
int
sctp_packet_transmit
(
struct
sctp_packet
*
packet
)
{
{
struct
sctp_transport
*
t
ransport
=
packet
->
transport
;
struct
sctp_transport
*
t
p
=
packet
->
transport
;
struct
sctp_association
*
asoc
=
t
ransport
->
asoc
;
struct
sctp_association
*
asoc
=
t
p
->
asoc
;
struct
sctphdr
*
sh
;
struct
sctphdr
*
sh
;
__u32
crc32
;
__u32
crc32
;
struct
sk_buff
*
nskb
;
struct
sk_buff
*
nskb
;
...
@@ -311,6 +311,32 @@ int sctp_packet_transmit(struct sctp_packet *packet)
...
@@ -311,6 +311,32 @@ int sctp_packet_transmit(struct sctp_packet *packet)
*/
*/
skb_set_owner_w
(
nskb
,
sk
);
skb_set_owner_w
(
nskb
,
sk
);
/* Build the SCTP header. */
sh
=
(
struct
sctphdr
*
)
skb_push
(
nskb
,
sizeof
(
struct
sctphdr
));
sh
->
source
=
htons
(
packet
->
source_port
);
sh
->
dest
=
htons
(
packet
->
destination_port
);
/* From 6.8 Adler-32 Checksum Calculation:
* After the packet is constructed (containing the SCTP common
* header and one or more control or DATA chunks), the
* transmitter shall:
*
* 1) Fill in the proper Verification Tag in the SCTP common
* header and initialize the checksum field to 0's.
*/
sh
->
vtag
=
htonl
(
packet
->
vtag
);
sh
->
checksum
=
0
;
/* 2) Calculate the Adler-32 checksum of the whole packet,
* including the SCTP common header and all the
* chunks.
*
* Note: Adler-32 is no longer applicable, as has been replaced
* by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>.
*/
crc32
=
sctp_start_cksum
((
__u8
*
)
sh
,
sizeof
(
struct
sctphdr
));
/**
/**
* 6.10 Bundling
* 6.10 Bundling
*
*
...
@@ -344,16 +370,20 @@ int sctp_packet_transmit(struct sctp_packet *packet)
...
@@ -344,16 +370,20 @@ int sctp_packet_transmit(struct sctp_packet *packet)
* for a given destination transport address.
* for a given destination transport address.
*/
*/
if
((
1
==
chunk
->
num_times_sent
)
&&
if
((
1
==
chunk
->
num_times_sent
)
&&
(
!
t
ransport
->
rto_pending
))
{
(
!
t
p
->
rto_pending
))
{
chunk
->
rtt_in_progress
=
1
;
chunk
->
rtt_in_progress
=
1
;
t
ransport
->
rto_pending
=
1
;
t
p
->
rto_pending
=
1
;
}
}
has_data
=
1
;
has_data
=
1
;
}
}
memcpy
(
skb_put
(
nskb
,
chunk
->
skb
->
len
),
chunk
->
skb
->
data
,
chunk
->
skb
->
len
);
padding
=
WORD_ROUND
(
chunk
->
skb
->
len
)
-
chunk
->
skb
->
len
;
padding
=
WORD_ROUND
(
chunk
->
skb
->
len
)
-
chunk
->
skb
->
len
;
memset
(
skb_put
(
nskb
,
padding
),
0
,
padding
);
if
(
padding
)
memset
(
skb_put
(
chunk
->
skb
,
padding
),
0
,
padding
);
crc32
=
sctp_update_copy_cksum
(
skb_put
(
nskb
,
chunk
->
skb
->
len
),
chunk
->
skb
->
data
,
chunk
->
skb
->
len
,
crc32
);
SCTP_DEBUG_PRINTK
(
"%s %p[%s] %s 0x%x, %s %d, %s %d, %s %d, "
SCTP_DEBUG_PRINTK
(
"%s %p[%s] %s 0x%x, %s %d, %s %d, %s %d, "
"%s %d
\n
"
,
"%s %d
\n
"
,
"*** Chunk"
,
chunk
,
"*** Chunk"
,
chunk
,
...
@@ -376,30 +406,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
...
@@ -376,30 +406,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
sctp_free_chunk
(
chunk
);
sctp_free_chunk
(
chunk
);
}
}
/* Build the SCTP header. */
/* Perform final transformation on checksum. */
sh
=
(
struct
sctphdr
*
)
skb_push
(
nskb
,
sizeof
(
struct
sctphdr
));
sh
->
source
=
htons
(
packet
->
source_port
);
sh
->
dest
=
htons
(
packet
->
destination_port
);
/* From 6.8 Adler-32 Checksum Calculation:
* After the packet is constructed (containing the SCTP common
* header and one or more control or DATA chunks), the
* transmitter shall:
*
* 1) Fill in the proper Verification Tag in the SCTP common
* header and initialize the checksum field to 0's.
*/
sh
->
vtag
=
htonl
(
packet
->
vtag
);
sh
->
checksum
=
0
;
/* 2) Calculate the Adler-32 checksum of the whole packet,
* including the SCTP common header and all the
* chunks.
*
* Note: Adler-32 is no longer applicable, as has been replaced
* by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>.
*/
crc32
=
sctp_start_cksum
((
__u8
*
)
sh
,
nskb
->
len
);
crc32
=
sctp_end_cksum
(
crc32
);
crc32
=
sctp_end_cksum
(
crc32
);
/* 3) Put the resultant value into the checksum field in the
/* 3) Put the resultant value into the checksum field in the
...
@@ -431,18 +438,18 @@ int sctp_packet_transmit(struct sctp_packet *packet)
...
@@ -431,18 +438,18 @@ int sctp_packet_transmit(struct sctp_packet *packet)
*/
*/
/* Dump that on IP! */
/* Dump that on IP! */
if
(
asoc
&&
asoc
->
peer
.
last_sent_to
!=
t
ransport
)
{
if
(
asoc
&&
asoc
->
peer
.
last_sent_to
!=
t
p
)
{
/* Considering the multiple CPU scenario, this is a
/* Considering the multiple CPU scenario, this is a
* "correcter" place for last_sent_to. --xguo
* "correcter" place for last_sent_to. --xguo
*/
*/
asoc
->
peer
.
last_sent_to
=
t
ransport
;
asoc
->
peer
.
last_sent_to
=
t
p
;
}
}
if
(
has_data
)
{
if
(
has_data
)
{
struct
timer_list
*
timer
;
struct
timer_list
*
timer
;
unsigned
long
timeout
;
unsigned
long
timeout
;
t
ransport
->
last_time_used
=
jiffies
;
t
p
->
last_time_used
=
jiffies
;
/* Restart the AUTOCLOSE timer when sending data. */
/* Restart the AUTOCLOSE timer when sending data. */
if
((
SCTP_STATE_ESTABLISHED
==
asoc
->
state
)
&&
if
((
SCTP_STATE_ESTABLISHED
==
asoc
->
state
)
&&
...
@@ -455,21 +462,21 @@ int sctp_packet_transmit(struct sctp_packet *packet)
...
@@ -455,21 +462,21 @@ int sctp_packet_transmit(struct sctp_packet *packet)
}
}
}
}
dst
=
t
ransport
->
dst
;
dst
=
t
p
->
dst
;
/* The 'obsolete' field of dst is set to 2 when a dst is freed. */
/* The 'obsolete' field of dst is set to 2 when a dst is freed. */
if
(
!
dst
||
(
dst
->
obsolete
>
1
))
{
if
(
!
dst
||
(
dst
->
obsolete
>
1
))
{
dst_release
(
dst
);
dst_release
(
dst
);
sctp_transport_route
(
t
ransport
,
NULL
,
sctp_sk
(
sk
));
sctp_transport_route
(
t
p
,
NULL
,
sctp_sk
(
sk
));
sctp_assoc_sync_pmtu
(
asoc
);
sctp_assoc_sync_pmtu
(
asoc
);
}
}
nskb
->
dst
=
dst_clone
(
t
ransport
->
dst
);
nskb
->
dst
=
dst_clone
(
t
p
->
dst
);
if
(
!
nskb
->
dst
)
if
(
!
nskb
->
dst
)
goto
no_route
;
goto
no_route
;
SCTP_DEBUG_PRINTK
(
"***sctp_transmit_packet*** skb length %d
\n
"
,
SCTP_DEBUG_PRINTK
(
"***sctp_transmit_packet*** skb length %d
\n
"
,
nskb
->
len
);
nskb
->
len
);
(
*
t
ransport
->
af_specific
->
sctp_xmit
)(
nskb
,
transport
,
packet
->
ipfragok
);
(
*
t
p
->
af_specific
->
sctp_xmit
)(
nskb
,
tp
,
packet
->
ipfragok
);
out:
out:
packet
->
size
=
SCTP_IP_OVERHEAD
;
packet
->
size
=
SCTP_IP_OVERHEAD
;
return
err
;
return
err
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment