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
2bbf8c1e
Commit
2bbf8c1e
authored
Apr 27, 2020
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ipv4: take handling of group_source_req options into a helper
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
2f984f11
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
39 deletions
+44
-39
net/ipv4/ip_sockglue.c
net/ipv4/ip_sockglue.c
+44
-39
No files found.
net/ipv4/ip_sockglue.c
View file @
2bbf8c1e
...
@@ -624,6 +624,49 @@ static int set_mcast_msfilter(struct sock *sk, int ifindex,
...
@@ -624,6 +624,49 @@ static int set_mcast_msfilter(struct sock *sk, int ifindex,
return
-
EADDRNOTAVAIL
;
return
-
EADDRNOTAVAIL
;
}
}
static
int
do_mcast_group_source
(
struct
sock
*
sk
,
int
optname
,
struct
group_source_req
*
greqs
)
{
struct
ip_mreq_source
mreqs
;
struct
sockaddr_in
*
psin
;
int
omode
,
add
,
err
;
if
(
greqs
->
gsr_group
.
ss_family
!=
AF_INET
||
greqs
->
gsr_source
.
ss_family
!=
AF_INET
)
return
-
EADDRNOTAVAIL
;
psin
=
(
struct
sockaddr_in
*
)
&
greqs
->
gsr_group
;
mreqs
.
imr_multiaddr
=
psin
->
sin_addr
.
s_addr
;
psin
=
(
struct
sockaddr_in
*
)
&
greqs
->
gsr_source
;
mreqs
.
imr_sourceaddr
=
psin
->
sin_addr
.
s_addr
;
mreqs
.
imr_interface
=
0
;
/* use index for mc_source */
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
ip_mreqn
mreq
;
psin
=
(
struct
sockaddr_in
*
)
&
greqs
->
gsr_group
;
mreq
.
imr_multiaddr
=
psin
->
sin_addr
;
mreq
.
imr_address
.
s_addr
=
0
;
mreq
.
imr_ifindex
=
greqs
->
gsr_interface
;
err
=
ip_mc_join_group_ssm
(
sk
,
&
mreq
,
MCAST_INCLUDE
);
if
(
err
&&
err
!=
-
EADDRINUSE
)
return
err
;
greqs
->
gsr_interface
=
mreq
.
imr_ifindex
;
omode
=
MCAST_INCLUDE
;
add
=
1
;
}
else
/* MCAST_LEAVE_SOURCE_GROUP */
{
omode
=
MCAST_INCLUDE
;
add
=
0
;
}
return
ip_mc_source
(
add
,
omode
,
sk
,
&
mreqs
,
greqs
->
gsr_interface
);
}
static
int
do_ip_setsockopt
(
struct
sock
*
sk
,
int
level
,
static
int
do_ip_setsockopt
(
struct
sock
*
sk
,
int
level
,
int
optname
,
char
__user
*
optval
,
unsigned
int
optlen
)
int
optname
,
char
__user
*
optval
,
unsigned
int
optlen
)
{
{
...
@@ -1066,9 +1109,6 @@ static int do_ip_setsockopt(struct sock *sk, int level,
...
@@ -1066,9 +1109,6 @@ static int do_ip_setsockopt(struct sock *sk, int level,
case
MCAST_UNBLOCK_SOURCE
:
case
MCAST_UNBLOCK_SOURCE
:
{
{
struct
group_source_req
greqs
;
struct
group_source_req
greqs
;
struct
ip_mreq_source
mreqs
;
struct
sockaddr_in
*
psin
;
int
omode
,
add
;
if
(
optlen
!=
sizeof
(
struct
group_source_req
))
if
(
optlen
!=
sizeof
(
struct
group_source_req
))
goto
e_inval
;
goto
e_inval
;
...
@@ -1076,42 +1116,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
...
@@ -1076,42 +1116,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
err
=
-
EFAULT
;
err
=
-
EFAULT
;
break
;
break
;
}
}
if
(
greqs
.
gsr_group
.
ss_family
!=
AF_INET
||
err
=
do_mcast_group_source
(
sk
,
optname
,
&
greqs
);
greqs
.
gsr_source
.
ss_family
!=
AF_INET
)
{
err
=
-
EADDRNOTAVAIL
;
break
;
}
psin
=
(
struct
sockaddr_in
*
)
&
greqs
.
gsr_group
;
mreqs
.
imr_multiaddr
=
psin
->
sin_addr
.
s_addr
;
psin
=
(
struct
sockaddr_in
*
)
&
greqs
.
gsr_source
;
mreqs
.
imr_sourceaddr
=
psin
->
sin_addr
.
s_addr
;
mreqs
.
imr_interface
=
0
;
/* use index for mc_source */
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
ip_mreqn
mreq
;
psin
=
(
struct
sockaddr_in
*
)
&
greqs
.
gsr_group
;
mreq
.
imr_multiaddr
=
psin
->
sin_addr
;
mreq
.
imr_address
.
s_addr
=
0
;
mreq
.
imr_ifindex
=
greqs
.
gsr_interface
;
err
=
ip_mc_join_group_ssm
(
sk
,
&
mreq
,
MCAST_INCLUDE
);
if
(
err
&&
err
!=
-
EADDRINUSE
)
break
;
greqs
.
gsr_interface
=
mreq
.
imr_ifindex
;
omode
=
MCAST_INCLUDE
;
add
=
1
;
}
else
/* MCAST_LEAVE_SOURCE_GROUP */
{
omode
=
MCAST_INCLUDE
;
add
=
0
;
}
err
=
ip_mc_source
(
add
,
omode
,
sk
,
&
mreqs
,
greqs
.
gsr_interface
);
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