Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
22a13778
Commit
22a13778
authored
Oct 19, 2012
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zdtm: Test that sockets bound to device work
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
b42f8fa1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
0 deletions
+61
-0
zdtm.sh
test/zdtm.sh
+1
-0
Makefile
test/zdtm/live/static/Makefile
+1
-0
sock_opts01.c
test/zdtm/live/static/sock_opts01.c
+59
-0
No files found.
test/zdtm.sh
View file @
22a13778
...
...
@@ -32,6 +32,7 @@ streaming/pipe_shared00
transition/file_read
static/sockets00
static/sock_opts00
static/sock_opts01
static/sockets_spair
static/sockets_dgram
static/socket_queues
...
...
test/zdtm/live/static/Makefile
View file @
22a13778
...
...
@@ -44,6 +44,7 @@ TST_NOFILE = \
socket_queues02
\
socket-tcp
\
sock_opts00
\
sock_opts01
\
ipc_namespace
\
selfexe00
\
sem
\
...
...
test/zdtm/live/static/sock_opts01.c
0 → 100644
View file @
22a13778
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <linux/if.h>
#include "zdtmtst.h"
const
char
*
test_doc
=
"Check that SO_BINDTODEVICE option works"
;
const
char
*
test_author
=
"Pavel Emelyanov <xemul@parallels.com>"
;
int
main
(
int
argc
,
char
**
argv
)
{
int
sock
,
ret
,
dev
,
dev2
;
socklen_t
len
=
sizeof
(
dev
);
test_init
(
argc
,
argv
);
sock
=
socket
(
PF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
if
(
sock
<
0
)
{
err
(
"can't create socket: %m"
);
return
1
;
}
ret
=
setsockopt
(
sock
,
SOL_SOCKET
,
SO_BINDTODEVICE
,
"eth0"
,
5
);
if
(
ret
<
0
)
ret
=
setsockopt
(
sock
,
SOL_SOCKET
,
SO_BINDTODEVICE
,
"lo"
,
3
);
if
(
ret
<
0
)
{
err
(
"can't bind to eth0"
);
return
1
;
}
ret
=
getsockopt
(
sock
,
SOL_SOCKET
,
SO_BINDTODEVICE
,
&
dev
,
&
len
);
if
(
ret
<
0
)
{
err
(
"can't get dev binding"
);
return
1
;
}
test_daemon
();
test_waitsig
();
ret
=
getsockopt
(
sock
,
SOL_SOCKET
,
SO_BINDTODEVICE
,
&
dev2
,
&
len
);
if
(
ret
<
0
)
{
fail
(
"can't get dev binding2"
);
return
1
;
}
if
(
!
dev2
)
fail
(
"unbound sock restored"
);
else
if
(
dev
!=
dev2
)
fail
(
"wrong bound device"
);
else
pass
();
close
(
sock
);
return
0
;
}
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