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
e986d4da
Commit
e986d4da
authored
Mar 29, 2020
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set_mcast_msfilter(): take the guts of setsockopt(MCAST_MSFILTER) into a helper
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
0dfe6581
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
33 deletions
+40
-33
net/ipv4/ip_sockglue.c
net/ipv4/ip_sockglue.c
+40
-33
No files found.
net/ipv4/ip_sockglue.c
View file @
e986d4da
...
...
@@ -587,6 +587,43 @@ static bool setsockopt_needs_rtnl(int optname)
return
false
;
}
static
int
set_mcast_msfilter
(
struct
sock
*
sk
,
int
ifindex
,
int
numsrc
,
int
fmode
,
struct
sockaddr_storage
*
group
,
struct
sockaddr_storage
*
list
)
{
int
msize
=
IP_MSFILTER_SIZE
(
numsrc
);
struct
ip_msfilter
*
msf
;
struct
sockaddr_in
*
psin
;
int
err
,
i
;
msf
=
kmalloc
(
msize
,
GFP_KERNEL
);
if
(
!
msf
)
return
-
ENOBUFS
;
psin
=
(
struct
sockaddr_in
*
)
group
;
if
(
psin
->
sin_family
!=
AF_INET
)
goto
Eaddrnotavail
;
msf
->
imsf_multiaddr
=
psin
->
sin_addr
.
s_addr
;
msf
->
imsf_interface
=
0
;
msf
->
imsf_fmode
=
fmode
;
msf
->
imsf_numsrc
=
numsrc
;
for
(
i
=
0
;
i
<
numsrc
;
++
i
)
{
psin
=
(
struct
sockaddr_in
*
)
&
list
[
i
];
if
(
psin
->
sin_family
!=
AF_INET
)
goto
Eaddrnotavail
;
msf
->
imsf_slist
[
i
]
=
psin
->
sin_addr
.
s_addr
;
}
err
=
ip_mc_msfilter
(
sk
,
msf
,
ifindex
);
kfree
(
msf
);
return
err
;
Eaddrnotavail:
kfree
(
msf
);
return
-
EADDRNOTAVAIL
;
}
static
int
do_ip_setsockopt
(
struct
sock
*
sk
,
int
level
,
int
optname
,
char
__user
*
optval
,
unsigned
int
optlen
)
{
...
...
@@ -1079,10 +1116,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
}
case
MCAST_MSFILTER
:
{
struct
sockaddr_in
*
psin
;
struct
ip_msfilter
*
msf
=
NULL
;
struct
group_filter
*
gsf
=
NULL
;
int
msize
,
i
,
ifindex
;
if
(
optlen
<
GROUP_FILTER_SIZE
(
0
))
goto
e_inval
;
...
...
@@ -1095,7 +1129,6 @@ static int do_ip_setsockopt(struct sock *sk, int level,
err
=
PTR_ERR
(
gsf
);
break
;
}
/* numsrc >= (4G-140)/128 overflow in 32 bits */
if
(
gsf
->
gf_numsrc
>=
0x1ffffff
||
gsf
->
gf_numsrc
>
net
->
ipv4
.
sysctl_igmp_max_msf
)
{
...
...
@@ -1106,36 +1139,10 @@ static int do_ip_setsockopt(struct sock *sk, int level,
err
=
-
EINVAL
;
goto
mc_msf_out
;
}
msize
=
IP_MSFILTER_SIZE
(
gsf
->
gf_numsrc
);
msf
=
kmalloc
(
msize
,
GFP_KERNEL
);
if
(
!
msf
)
{
err
=
-
ENOBUFS
;
goto
mc_msf_out
;
}
ifindex
=
gsf
->
gf_interface
;
psin
=
(
struct
sockaddr_in
*
)
&
gsf
->
gf_group
;
if
(
psin
->
sin_family
!=
AF_INET
)
{
err
=
-
EADDRNOTAVAIL
;
goto
mc_msf_out
;
}
msf
->
imsf_multiaddr
=
psin
->
sin_addr
.
s_addr
;
msf
->
imsf_interface
=
0
;
msf
->
imsf_fmode
=
gsf
->
gf_fmode
;
msf
->
imsf_numsrc
=
gsf
->
gf_numsrc
;
err
=
-
EADDRNOTAVAIL
;
for
(
i
=
0
;
i
<
gsf
->
gf_numsrc
;
++
i
)
{
psin
=
(
struct
sockaddr_in
*
)
&
gsf
->
gf_slist
[
i
];
if
(
psin
->
sin_family
!=
AF_INET
)
goto
mc_msf_out
;
msf
->
imsf_slist
[
i
]
=
psin
->
sin_addr
.
s_addr
;
}
kfree
(
gsf
);
gsf
=
NULL
;
err
=
ip_mc_msfilter
(
sk
,
msf
,
ifindex
);
err
=
set_mcast_msfilter
(
sk
,
gsf
->
gf_interface
,
gsf
->
gf_numsrc
,
gsf
->
gf_fmode
,
&
gsf
->
gf_group
,
gsf
->
gf_slist
);
mc_msf_out:
kfree
(
msf
);
kfree
(
gsf
);
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