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
fcfa0b09
Commit
fcfa0b09
authored
Apr 27, 2020
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ipv6: take handling of group_source_req options into a helper
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
2bbf8c1e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
29 deletions
+36
-29
net/ipv6/ipv6_sockglue.c
net/ipv6/ipv6_sockglue.c
+36
-29
No files found.
net/ipv6/ipv6_sockglue.c
View file @
fcfa0b09
...
@@ -136,6 +136,41 @@ static bool setsockopt_needs_rtnl(int optname)
...
@@ -136,6 +136,41 @@ static bool setsockopt_needs_rtnl(int optname)
return
false
;
return
false
;
}
}
static
int
do_ipv6_mcast_group_source
(
struct
sock
*
sk
,
int
optname
,
struct
group_source_req
*
greqs
)
{
int
omode
,
add
;
if
(
greqs
->
gsr_group
.
ss_family
!=
AF_INET6
||
greqs
->
gsr_source
.
ss_family
!=
AF_INET6
)
return
-
EADDRNOTAVAIL
;
if
(
optname
==
MCAST_BLOCK_SOURCE
)
{
omode
=
MCAST_EXCLUDE
;
add
=
1
;
}
else
if
(
optname
==
MCAST_UNBLOCK_SOURCE
)
{
omode
=
MCAST_EXCLUDE
;
add
=
0
;
}
else
if
(
optname
==
MCAST_JOIN_SOURCE_GROUP
)
{
struct
sockaddr_in6
*
psin6
;
int
retv
;
psin6
=
(
struct
sockaddr_in6
*
)
&
greqs
->
gsr_group
;
retv
=
ipv6_sock_mc_join_ssm
(
sk
,
greqs
->
gsr_interface
,
&
psin6
->
sin6_addr
,
MCAST_INCLUDE
);
/* prior join w/ different source is ok */
if
(
retv
&&
retv
!=
-
EADDRINUSE
)
return
retv
;
omode
=
MCAST_INCLUDE
;
add
=
1
;
}
else
/* MCAST_LEAVE_SOURCE_GROUP */
{
omode
=
MCAST_INCLUDE
;
add
=
0
;
}
return
ip6_mc_source
(
add
,
omode
,
sk
,
greqs
);
}
static
int
do_ipv6_setsockopt
(
struct
sock
*
sk
,
int
level
,
int
optname
,
static
int
do_ipv6_setsockopt
(
struct
sock
*
sk
,
int
level
,
int
optname
,
char
__user
*
optval
,
unsigned
int
optlen
)
char
__user
*
optval
,
unsigned
int
optlen
)
{
{
...
@@ -715,7 +750,6 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
...
@@ -715,7 +750,6 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
case
MCAST_UNBLOCK_SOURCE
:
case
MCAST_UNBLOCK_SOURCE
:
{
{
struct
group_source_req
greqs
;
struct
group_source_req
greqs
;
int
omode
,
add
;
if
(
optlen
<
sizeof
(
struct
group_source_req
))
if
(
optlen
<
sizeof
(
struct
group_source_req
))
goto
e_inval
;
goto
e_inval
;
...
@@ -723,34 +757,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
...
@@ -723,34 +757,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
retv
=
-
EFAULT
;
retv
=
-
EFAULT
;
break
;
break
;
}
}
if
(
greqs
.
gsr_group
.
ss_family
!=
AF_INET6
||
retv
=
do_ipv6_mcast_group_source
(
sk
,
optname
,
&
greqs
);
greqs
.
gsr_source
.
ss_family
!=
AF_INET6
)
{
retv
=
-
EADDRNOTAVAIL
;
break
;
}
if
(
optname
==
MCAST_BLOCK_SOURCE
)
{
omode
=
MCAST_EXCLUDE
;
add
=
1
;
}
else
if
(
optname
==
MCAST_UNBLOCK_SOURCE
)
{
omode
=
MCAST_EXCLUDE
;
add
=
0
;
}
else
if
(
optname
==
MCAST_JOIN_SOURCE_GROUP
)
{
struct
sockaddr_in6
*
psin6
;
psin6
=
(
struct
sockaddr_in6
*
)
&
greqs
.
gsr_group
;
retv
=
ipv6_sock_mc_join_ssm
(
sk
,
greqs
.
gsr_interface
,
&
psin6
->
sin6_addr
,
MCAST_INCLUDE
);
/* prior join w/ different source is ok */
if
(
retv
&&
retv
!=
-
EADDRINUSE
)
break
;
omode
=
MCAST_INCLUDE
;
add
=
1
;
}
else
/* MCAST_LEAVE_SOURCE_GROUP */
{
omode
=
MCAST_INCLUDE
;
add
=
0
;
}
retv
=
ip6_mc_source
(
add
,
omode
,
sk
,
&
greqs
);
break
;
break
;
}
}
case
MCAST_MSFILTER
:
case
MCAST_MSFILTER
:
...
...
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