Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
HardenedBSD
HardenedBSD
Commits
a01b8859
Commit
a01b8859
authored
Dec 01, 2021
by
Michael Tuexen
Browse files
sctp: cleanup, no functional change intended.
MFC after: 1 week
parent
cbe9faa5
Changes
1
Hide whitespace changes
Inline
Side-by-side
sys/netinet/sctp_usrreq.c
View file @
a01b8859
...
...
@@ -1228,7 +1228,7 @@ sctp_fill_up_addresses(struct sctp_inpcb *inp,
size_t
limit
,
struct
sockaddr
*
addr
)
{
size_t
size
=
0
;
size_t
size
;
SCTP_IPI_ADDR_RLOCK
();
/* fill up addresses for the endpoint's default vrf */
...
...
@@ -1238,17 +1238,17 @@ sctp_fill_up_addresses(struct sctp_inpcb *inp,
return
(
size
);
}
static
in
t
sctp_
count_max
_addresses_vrf
(
struct
sctp_inpcb
*
inp
,
uint32_t
vrf_id
)
static
size_
t
sctp_
max_size
_addresses_vrf
(
struct
sctp_inpcb
*
inp
,
uint32_t
vrf_id
)
{
int
cnt
=
0
;
s
truct
sctp_vrf
*
vrf
=
NULL
;
struct
sctp_vrf
*
vrf
;
s
ize_t
size
;
/*
* In both sub-set bound an bound_all cases we return the
MAXIMUM
* number of addresses that you
COULD
get. In reality
the sub-set
* bound may have an exclusion list for a given TCB
OR in the
* bound-all case a TCB may NOT include the loopback or other
* In both sub-set bound an bound_all cases we return the
size of
*
the maximum
number of addresses that you
could
get. In reality
*
the sub-set
bound may have an exclusion list for a given TCB
or
*
in the
bound-all case a TCB may NOT include the loopback or other
* addresses as well.
*/
SCTP_IPI_ADDR_LOCK_ASSERT
();
...
...
@@ -1256,6 +1256,7 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id)
if
(
vrf
==
NULL
)
{
return
(
0
);
}
size
=
0
;
if
(
inp
->
sctp_flags
&
SCTP_PCB_FLAGS_BOUNDALL
)
{
struct
sctp_ifn
*
sctp_ifn
;
struct
sctp_ifa
*
sctp_ifa
;
...
...
@@ -1268,17 +1269,17 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id)
case
AF_INET
:
#ifdef INET6
if
(
sctp_is_feature_on
(
inp
,
SCTP_PCB_FLAGS_NEEDS_MAPPED_V4
))
cnt
+=
sizeof
(
struct
sockaddr_in6
);
size
+=
sizeof
(
struct
sockaddr_in6
);
else
cnt
+=
sizeof
(
struct
sockaddr_in
);
size
+=
sizeof
(
struct
sockaddr_in
);
#else
cnt
+=
sizeof
(
struct
sockaddr_in
);
size
+=
sizeof
(
struct
sockaddr_in
);
#endif
break
;
#endif
#ifdef INET6
case
AF_INET6
:
cnt
+=
sizeof
(
struct
sockaddr_in6
);
size
+=
sizeof
(
struct
sockaddr_in6
);
break
;
#endif
default:
...
...
@@ -1295,17 +1296,17 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id)
case
AF_INET
:
#ifdef INET6
if
(
sctp_is_feature_on
(
inp
,
SCTP_PCB_FLAGS_NEEDS_MAPPED_V4
))
cnt
+=
sizeof
(
struct
sockaddr_in6
);
size
+=
sizeof
(
struct
sockaddr_in6
);
else
cnt
+=
sizeof
(
struct
sockaddr_in
);
size
+=
sizeof
(
struct
sockaddr_in
);
#else
cnt
+=
sizeof
(
struct
sockaddr_in
);
size
+=
sizeof
(
struct
sockaddr_in
);
#endif
break
;
#endif
#ifdef INET6
case
AF_INET6
:
cnt
+=
sizeof
(
struct
sockaddr_in6
);
size
+=
sizeof
(
struct
sockaddr_in6
);
break
;
#endif
default:
...
...
@@ -1313,19 +1314,19 @@ sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id)
}
}
}
return
(
cnt
);
return
(
size
);
}
static
in
t
sctp_
count_max
_addresses
(
struct
sctp_inpcb
*
inp
)
static
size_
t
sctp_
max_size
_addresses
(
struct
sctp_inpcb
*
inp
)
{
int
cnt
=
0
;
size_t
size
;
SCTP_IPI_ADDR_RLOCK
();
/*
count
addresses for the endpoint's default VRF */
cnt
=
sctp_
count_max
_addresses_vrf
(
inp
,
inp
->
def_vrf_id
);
/*
Maximum size of all
addresses for the endpoint's default VRF */
size
=
sctp_
max_size
_addresses_vrf
(
inp
,
inp
->
def_vrf_id
);
SCTP_IPI_ADDR_RUNLOCK
();
return
(
cnt
);
return
(
size
);
}
static
int
...
...
@@ -2140,7 +2141,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
SCTP_CHECK_AND_CAST
(
value
,
optval
,
uint32_t
,
*
optsize
);
SCTP_INP_RLOCK
(
inp
);
*
value
=
sctp_count_max
_addresses
(
inp
);
*
value
=
(
uint32_t
)
sctp_max_size
_addresses
(
inp
);
SCTP_INP_RUNLOCK
(
inp
);
*
optsize
=
sizeof
(
uint32_t
);
break
;
...
...
@@ -2148,14 +2149,14 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
case
SCTP_GET_REMOTE_ADDR_SIZE
:
{
uint32_t
*
value
;
size_t
size
;
struct
sctp_nets
*
net
;
size_t
size
;
SCTP_CHECK_AND_CAST
(
value
,
optval
,
uint32_t
,
*
optsize
);
/* FIXME MT: change to sctp_assoc_value? */
SCTP_FIND_STCB
(
inp
,
stcb
,
(
sctp_assoc_t
)
*
value
);
if
(
stcb
)
{
if
(
stcb
!=
NULL
)
{
size
=
0
;
/* Count the sizes */
TAILQ_FOREACH
(
net
,
&
stcb
->
asoc
.
nets
,
sctp_next
)
{
...
...
@@ -2205,7 +2206,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
SCTP_CHECK_AND_CAST
(
saddr
,
optval
,
struct
sctp_getaddresses
,
*
optsize
);
SCTP_FIND_STCB
(
inp
,
stcb
,
saddr
->
sget_assoc_id
);
if
(
stcb
)
{
if
(
stcb
!=
NULL
)
{
left
=
*
optsize
-
offsetof
(
struct
sctp_getaddresses
,
addr
);
*
optsize
=
offsetof
(
struct
sctp_getaddresses
,
addr
);
addr
=
&
saddr
->
addr
[
0
].
sa
;
...
...
@@ -2276,7 +2277,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
limit
=
*
optsize
-
offsetof
(
struct
sctp_getaddresses
,
addr
);
actual
=
sctp_fill_up_addresses
(
inp
,
stcb
,
limit
,
&
saddr
->
addr
[
0
].
sa
);
if
(
stcb
)
{
if
(
stcb
!=
NULL
)
{
SCTP_TCB_UNLOCK
(
stcb
);
}
*
optsize
=
offsetof
(
struct
sctp_getaddresses
,
addr
)
+
actual
;
...
...
HardenedBSD Services
@hardenedbsd-services
mentioned in commit
6f7ab8ac
·
Dec 10, 2021
mentioned in commit
6f7ab8ac
mentioned in commit 6f7ab8ac9e4fbfdec036a02e4b7486bf8704e624
Toggle commit list
Write
Preview
Supports
Markdown
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