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
nexedi
linux
Commits
b5c67280
Commit
b5c67280
authored
Aug 27, 2003
by
Sridhar Samudrala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SCTP] SCTP_SET_PEER_PRIMARY socket option support. (Kevin Gao)
parent
bfaa8bf5
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
166 additions
and
10 deletions
+166
-10
include/linux/sctp.h
include/linux/sctp.h
+8
-1
include/net/sctp/sctp.h
include/net/sctp/sctp.h
+3
-1
include/net/sctp/sm.h
include/net/sctp/sm.h
+5
-1
include/net/sctp/structs.h
include/net/sctp/structs.h
+4
-1
net/sctp/associola.c
net/sctp/associola.c
+22
-1
net/sctp/primitive.c
net/sctp/primitive.c
+14
-0
net/sctp/sm_make_chunk.c
net/sctp/sm_make_chunk.c
+46
-2
net/sctp/socket.c
net/sctp/socket.c
+64
-3
No files found.
include/linux/sctp.h
View file @
b5c67280
/* SCTP kernel reference Implementation
* (C) Copyright IBM Corp. 2001, 2003
* Copyright (c) 1999-2000 Cisco, Inc.
* Copyright (c) 1999-2001 Motorola, Inc.
* Copyright (c) 2001-2002 International Business Machines, Corp.
* Copyright (c) 2001 Intel Corp.
* Copyright (c) 2001 Nokia, Inc.
* Copyright (c) 2001 La Monte H.P. Yarroll
...
...
@@ -42,6 +42,8 @@
* randall@sctp.chicago.il.us
* kmorneau@cisco.com
* qxie1@email.mot.com
* Sridhar Samudrala <sri@us.ibm.com>
* Kevin Gao <kevin.gao@intel.com>
*
* Any bugs reported given to us we will try to fix... any fixes shared will
* be incorporated into the next SCTP release.
...
...
@@ -507,6 +509,11 @@ typedef struct sctp_cwr_chunk {
* The ASCONF Parameter Response is used in the ASCONF-ACK to
* report status of ASCONF processing.
*/
typedef
struct
sctp_addip_param
{
sctp_paramhdr_t
param_hdr
;
__u32
crr_id
;
}
sctp_addip_param_t
__attribute__
((
packed
));
typedef
struct
sctp_addiphdr
{
__u32
serial
;
__u8
params
[
0
];
...
...
include/net/sctp/sctp.h
View file @
b5c67280
/* SCTP kernel reference Implementation
* (C) Copyright IBM Corp. 2001, 2003
* Copyright (c) 1999-2000 Cisco, Inc.
* Copyright (c) 1999-2001 Motorola, Inc.
* Copyright (c) 2001-2003 International Business Machines, Corp.
* Copyright (c) 2001-2003 Intel Corp.
*
* This file is part of the SCTP kernel reference Implementation
...
...
@@ -40,6 +40,7 @@
* Sridhar Samudrala <sri@us.ibm.com>
* Ardelle Fan <ardelle.fan@intel.com>
* Ryan Layer <rmlayer@us.ibm.com>
* Kevin Gao <kevin.gao@intel.com>
*
* Any bugs reported given to us we will try to fix... any fixes shared will
* be incorporated into the next SCTP release.
...
...
@@ -145,6 +146,7 @@ int sctp_primitive_SHUTDOWN(struct sctp_association *, void *arg);
int
sctp_primitive_ABORT
(
struct
sctp_association
*
,
void
*
arg
);
int
sctp_primitive_SEND
(
struct
sctp_association
*
,
void
*
arg
);
int
sctp_primitive_REQUESTHEARTBEAT
(
struct
sctp_association
*
,
void
*
arg
);
int
sctp_primitive_ASCONF
(
struct
sctp_association
*
,
void
*
arg
);
/*
* sctp/crc32c.c
...
...
include/net/sctp/sm.h
View file @
b5c67280
/* SCTP kernel reference Implementation
* (C) Copyright IBM Corp. 2001, 2003
* Copyright (c) 1999-2000 Cisco, Inc.
* Copyright (c) 1999-2001 Motorola, Inc.
* Copyright (c) 2001 Intel Corp.
* Copyright (c) 2001-2002 International Business Machines Corp.
*
* This file is part of the SCTP kernel reference Implementation
*
...
...
@@ -41,6 +41,7 @@
* Sridhar Samudrala <sri@us.ibm.com>
* Daisy Chang <daisyc@us.ibm.com>
* Ardelle Fan <ardelle.fan@intel.com>
* Kevin Gao <kevin.gao@intel.com>
*
* Any bugs reported given to us we will try to fix... any fixes shared will
* be incorporated into the next SCTP release.
...
...
@@ -268,6 +269,9 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
struct
sctp_chunk
*
asconf
,
int
vparam_len
);
struct
sctp_chunk
*
sctp_make_asconf_set_prim
(
struct
sctp_association
*
asoc
,
union
sctp_addr
*
addr
);
void
sctp_chunk_assign_tsn
(
struct
sctp_chunk
*
);
void
sctp_chunk_assign_ssn
(
struct
sctp_chunk
*
);
...
...
include/net/sctp/structs.h
View file @
b5c67280
/* SCTP kernel reference Implementation
* (C) Copyright IBM Corp. 2001, 2003
* Copyright (c) 1999-2000 Cisco, Inc.
* Copyright (c) 1999-2001 Motorola, Inc.
* Copyright (c) 2001 Intel Corp.
* Copyright (c) 2001-2003 International Business Machines Corp.
*
* This file is part of the SCTP kernel reference Implementation
*
...
...
@@ -45,6 +45,7 @@
* Ardelle Fan <ardelle.fan@intel.com>
* Ryan Layer <rmlayer@us.ibm.com>
* Anup Pemmaiah <pemmaiah@cc.usu.edu>
* Kevin Gao <kevin.gao@intel.com>
*
* Any bugs reported given to us we will try to fix... any fixes shared will
* be incorporated into the next SCTP release.
...
...
@@ -1688,6 +1689,8 @@ struct sctp_transport *sctp_assoc_choose_shutdown_transport(
void
sctp_assoc_update_retran_path
(
struct
sctp_association
*
);
struct
sctp_transport
*
sctp_assoc_lookup_paddr
(
const
struct
sctp_association
*
,
const
union
sctp_addr
*
);
int
sctp_assoc_lookup_laddr
(
struct
sctp_association
*
asoc
,
const
union
sctp_addr
*
laddr
);
struct
sctp_transport
*
sctp_assoc_add_peer
(
struct
sctp_association
*
,
const
union
sctp_addr
*
address
,
const
int
gfp
);
...
...
net/sctp/associola.c
View file @
b5c67280
/* SCTP kernel reference Implementation
* (C) Copyright IBM Corp. 2001, 2003
* Copyright (c) 1999-2000 Cisco, Inc.
* Copyright (c) 1999-2001 Motorola, Inc.
* Copyright (c) 2001-2003 International Business Machines Corp.
* Copyright (c) 2001 Intel Corp.
* Copyright (c) 2001 La Monte H.P. Yarroll
*
...
...
@@ -42,6 +42,7 @@
* Sridhar Samudrala <sri@us.ibm.com>
* Daisy Chang <daisyc@us.ibm.com>
* Ryan Layer <rmlayer@us.ibm.com>
* Kevin Gao <kevin.gao@intel.com>
*
* Any bugs reported given to us we will try to fix... any fixes shared will
* be incorporated into the next SCTP release.
...
...
@@ -1155,3 +1156,23 @@ int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *asoc,
return
sctp_raw_to_bind_addrs
(
&
asoc
->
base
.
bind_addr
,
raw
,
var_size3
,
asoc
->
ep
->
base
.
bind_addr
.
port
,
gfp
);
}
/* Lookup laddr in the bind address list of an association. */
int
sctp_assoc_lookup_laddr
(
struct
sctp_association
*
asoc
,
const
union
sctp_addr
*
laddr
)
{
int
found
;
sctp_read_lock
(
&
asoc
->
base
.
addr_lock
);
if
((
asoc
->
base
.
bind_addr
.
port
==
ntohs
(
laddr
->
v4
.
sin_port
))
&&
sctp_bind_addr_match
(
&
asoc
->
base
.
bind_addr
,
laddr
,
sctp_sk
(
asoc
->
base
.
sk
)))
{
found
=
1
;
goto
out
;
}
found
=
0
;
out:
sctp_read_unlock
(
&
asoc
->
base
.
addr_lock
);
return
found
;
}
net/sctp/primitive.c
View file @
b5c67280
...
...
@@ -39,6 +39,7 @@
* Narasimha Budihal <narasimha@refcode.org>
* Karl Knutson <karl@athena.chicago.il.us>
* Ardelle Fan <ardelle.fan@intel.com>
* Kevin Gao <kevin.gao@intel.com>
*
* Any bugs reported given to us we will try to fix... any fixes shared will
* be incorporated into the next SCTP release.
...
...
@@ -203,3 +204,16 @@ DECLARE_PRIMITIVE(SEND);
*/
DECLARE_PRIMITIVE
(
REQUESTHEARTBEAT
);
/* ADDIP
* 3.1.1 Address Configuration Change Chunk (ASCONF)
*
* This chunk is used to communicate to the remote endpoint one of the
* configuration change requests that MUST be acknowledged. The
* information carried in the ASCONF Chunk uses the form of a
* Type-Length-Value (TLV), as described in "3.2.1 Optional/
* Variable-length Parameter Format" in RFC2960 [5], forall variable
* parameters.
*/
DECLARE_PRIMITIVE
(
ASCONF
);
net/sctp/sm_make_chunk.c
View file @
b5c67280
/* SCTP kernel reference Implementation
* Copyright (C) IBM Corp. 2001, 2003
* Copyright (c) 1999-2000 Cisco, Inc.
* Copyright (c) 1999-2001 Motorola, Inc.
* Copyright (c) 2001-2002 Intel Corp.
* Copyright (c) 2001-2002 International Business Machines Corp.
*
* This file is part of the SCTP kernel reference Implementation
*
...
...
@@ -48,6 +48,7 @@
* Sridhar Samudrala <sri@us.ibm.com>
* Daisy Chang <daisyc@us.ibm.com>
* Ardelle Fan <ardelle.fan@intel.com>
* Kevin Gao <kevin.gao@intel.com>
*
* Any bugs reported given to us we will try to fix... any fixes shared will
* be incorporated into the next SCTP release.
...
...
@@ -2135,7 +2136,50 @@ struct sctp_chunk *sctp_make_asconf(struct sctp_association *asoc,
retval
->
subh
.
addip_hdr
=
sctp_addto_chunk
(
retval
,
sizeof
(
asconf
),
&
asconf
);
retval
->
param_hdr
.
v
=
sctp_addto_chunk
(
retval
,
addrlen
,
&
addr
);
sctp_addto_chunk
(
retval
,
addrlen
,
&
addrparam
);
return
retval
;
}
/* ADDIP
* 3.2.4 Set Primary IP Address
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Type =0xC004 | Length = Variable |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | ASCONF-Request Correlation ID |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Address Parameter |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* Create an ASCONF chunk with Set Primary IP address parameter.
*/
struct
sctp_chunk
*
sctp_make_asconf_set_prim
(
struct
sctp_association
*
asoc
,
union
sctp_addr
*
addr
)
{
sctp_addip_param_t
param
;
struct
sctp_chunk
*
retval
;
int
len
=
sizeof
(
param
);
union
sctp_params
addrparam
;
int
addrlen
;
addrlen
=
sockaddr2sctp_addr
(
addr
,
(
union
sctp_addr_param
*
)
&
addrparam
);
if
(
!
addrlen
)
return
NULL
;
len
+=
addrlen
;
/* Create the chunk and make asconf header. */
retval
=
sctp_make_asconf
(
asoc
,
addr
,
len
);
if
(
!
retval
)
return
NULL
;
param
.
param_hdr
.
type
=
SCTP_PARAM_SET_PRIMARY
;
param
.
param_hdr
.
length
=
htons
(
len
);
param
.
crr_id
=
0
;
sctp_addto_chunk
(
retval
,
sizeof
(
param
),
&
param
);
sctp_addto_chunk
(
retval
,
addrlen
,
&
addrparam
);
return
retval
;
}
...
...
net/sctp/socket.c
View file @
b5c67280
/* Copyright (c) 1999-2000 Cisco, Inc.
/* SCTP kernel reference Implementation
* (C) Copyright IBM Corp. 2001, 2003
* Copyright (c) 1999-2000 Cisco, Inc.
* Copyright (c) 1999-2001 Motorola, Inc.
* Copyright (c) 2001-2003 International Business Machines, Corp.
* Copyright (c) 2001-2003 Intel Corp.
* Copyright (c) 2001-2002 Nokia, Inc.
* Copyright (c) 2001 La Monte H.P. Yarroll
...
...
@@ -50,6 +51,7 @@
* Ardelle Fan <ardelle.fan@intel.com>
* Ryan Layer <rmlayer@us.ibm.com>
* Anup Pemmaiah <pemmaiah@cc.usu.edu>
* Kevin Gao <kevin.gao@intel.com>
*
* Any bugs reported given to us we will try to fix... any fixes shared will
* be incorporated into the next SCTP release.
...
...
@@ -1522,7 +1524,7 @@ static int sctp_setsockopt_default_send_param(struct sock *sk,
return
0
;
}
/* 7.1.10 Set P
eer P
rimary Address (SCTP_PRIMARY_ADDR)
/* 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR)
*
* Requests that the local SCTP stack use the enclosed peer address as
* the association primary. The enclosed address must be one of the
...
...
@@ -1727,6 +1729,62 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char *optval, int optlen)
return
0
;
}
/*
* 7.1.9 Set Peer Primary Address (SCTP_SET_PEER_PRIMARY_ADDR)
*
* Requests that the peer mark the enclosed address as the association
* primary. The enclosed address must be one of the association's
* locally bound addresses. The following structure is used to make a
* set primary request:
*/
static
int
sctp_setsockopt_peer_primary_addr
(
struct
sock
*
sk
,
char
*
optval
,
int
optlen
)
{
struct
sctp_opt
*
sp
;
struct
sctp_endpoint
*
ep
;
struct
sctp_association
*
asoc
=
NULL
;
struct
sctp_setpeerprim
prim
;
struct
sctp_chunk
*
chunk
;
int
err
;
sp
=
sctp_sk
(
sk
);
ep
=
sp
->
ep
;
if
(
optlen
!=
sizeof
(
struct
sctp_setpeerprim
))
return
-
EINVAL
;
if
(
copy_from_user
(
&
prim
,
optval
,
optlen
))
return
-
EFAULT
;
asoc
=
sctp_id2assoc
(
sk
,
prim
.
sspp_assoc_id
);
if
(
!
asoc
)
return
-
EINVAL
;
if
(
!
sctp_state
(
asoc
,
ESTABLISHED
))
return
-
ENOTCONN
;
if
(
!
sctp_assoc_lookup_laddr
(
asoc
,
(
union
sctp_addr
*
)
&
prim
.
sspp_addr
))
return
-
EADDRNOTAVAIL
;
/* Create an ASCONF chunk with SET_PRIMARY parameter */
chunk
=
sctp_make_asconf_set_prim
(
asoc
,
(
union
sctp_addr
*
)
&
prim
.
sspp_addr
);
if
(
!
chunk
)
return
-
ENOMEM
;
err
=
sctp_primitive_ASCONF
(
asoc
,
chunk
);
if
(
err
)
{
sctp_chunk_free
(
chunk
);
return
err
;
}
SCTP_DEBUG_PRINTK
(
"We set peer primary addr primitively.
\n
"
);
return
0
;
}
/* API 6.2 setsockopt(), getsockopt()
*
* Applications use setsockopt() and getsockopt() to set or retrieve
...
...
@@ -1809,6 +1867,9 @@ SCTP_STATIC int sctp_setsockopt(struct sock *sk, int level, int optname,
case
SCTP_PRIMARY_ADDR
:
retval
=
sctp_setsockopt_primary_addr
(
sk
,
optval
,
optlen
);
break
;
case
SCTP_SET_PEER_PRIMARY_ADDR
:
retval
=
sctp_setsockopt_peer_primary_addr
(
sk
,
optval
,
optlen
);
break
;
case
SCTP_NODELAY
:
retval
=
sctp_setsockopt_nodelay
(
sk
,
optval
,
optlen
);
break
;
...
...
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