Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
e624b193
Commit
e624b193
authored
Jun 17, 2007
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More tweaks to netlink debugging code.
parent
b31d4850
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
26 deletions
+15
-26
kernel.c
kernel.c
+15
-26
No files found.
kernel.c
View file @
e624b193
...
...
@@ -145,8 +145,6 @@ netlink_socket(struct netlink *nl, uint32_t groups)
static
int
netlink_read
(
int
(
*
filter
)(
struct
nlmsghdr
*
,
void
*
data
),
void
*
data
)
{
int
err
;
struct
sockaddr_nl
nladdr
;
struct
msghdr
msg
;
struct
iovec
iov
;
...
...
@@ -198,7 +196,7 @@ netlink_read(int (*filter)(struct nlmsghdr *, void *data), void *data)
for
(
nh
=
(
struct
nlmsghdr
*
)
buf
;
NLMSG_OK
(
nh
,
len
);
nh
=
NLMSG_NEXT
(
nh
,
len
))
{
debugf
(
"
nh
%d %s"
,
i
,
debugf
(
"%d %s"
,
i
,
(
nh
->
nlmsg_flags
&
NLM_F_MULTI
)
?
"(multi) "
:
""
);
i
++
;
if
(
nh
->
nlmsg_pid
!=
nl_command
.
sockaddr
.
nl_pid
||
...
...
@@ -206,8 +204,8 @@ netlink_read(int (*filter)(struct nlmsghdr *, void *data), void *data)
debugf
(
"(wrong seqno/pid), "
);
continue
;
}
else
if
(
nh
->
nlmsg_type
==
NLMSG_DONE
)
{
debugf
(
"
done
\n
"
);
return
0
;
debugf
(
"
(done)
\n
"
);
goto
done
;
}
else
if
(
nh
->
nlmsg_type
==
NLMSG_ERROR
)
{
struct
nlmsgerr
*
err
=
(
struct
nlmsgerr
*
)
NLMSG_DATA
(
nh
);
if
(
err
->
error
==
0
)
{
...
...
@@ -236,6 +234,7 @@ netlink_read(int (*filter)(struct nlmsghdr *, void *data), void *data)
}
}
done:
return
0
;
}
...
...
@@ -340,7 +339,7 @@ netlink_listen(int (*monitor)(struct nlmsghdr *nh, void *data), void *data) {
struct
sockaddr_nl
nladdr
;
struct
iovec
iov
;
struct
nlmsghdr
*
nh
;
int
len
,
i
;
int
len
;
int
interesting
=
0
;
static
char
buf
[
8192
];
...
...
@@ -362,46 +361,36 @@ netlink_listen(int (*monitor)(struct nlmsghdr *nh, void *data), void *data) {
iov
.
iov_base
=
buf
;
iov
.
iov_len
=
sizeof
(
buf
);
// TODO non block ??
len
=
recvmsg
(
nl_listen
.
sock
,
&
msg
,
0
);
debugf
(
"netlink_listen: recvmsg
\n
"
);
if
(
len
<
0
)
{
if
(
errno
==
EINTR
)
return
0
;
perror
(
"
OVERRUN
"
);
perror
(
"
recvmsg(netlink)
"
);
return
-
1
;
}
if
(
len
==
0
)
{
fprintf
(
stderr
,
"
netlink_listen: EOF on netlink
\n
"
);
fprintf
(
stderr
,
"
recvmsg(netlink): EOF
\n
"
);
return
-
1
;
}
if
(
msg
.
msg_namelen
!=
nl_listen
.
socklen
)
{
fprintf
(
stderr
,
"netlink_listen: sender address length == %d
\n
"
,
fprintf
(
stderr
,
"netlink_listen: unexpected sender address length (%d)
\n
"
,
msg
.
msg_namelen
);
return
-
1
;
}
for
(
nh
=
(
struct
nlmsghdr
*
)
buf
,
i
=
1
;
NLMSG_OK
(
nh
,
len
);
nh
=
NLMSG_NEXT
(
nh
,
len
),
i
++
)
{
debugf
(
"netlink_listen: nh: %d (multi : %s) : "
,
i
,
(
nh
->
nlmsg_flags
&
NLM_F_MULTI
)
?
"yes"
:
"no"
);
for
(
nh
=
(
struct
nlmsghdr
*
)
buf
;
NLMSG_OK
(
nh
,
len
);
nh
=
NLMSG_NEXT
(
nh
,
len
))
{
if
(
nh
->
nlmsg_type
==
NLMSG_DONE
)
{
debugf
(
"netlink_listen: DONE
\n
"
);
continue
;
}
if
(
nh
->
nlmsg_type
==
NLMSG_ERROR
)
{
debugf
(
"netlink_listen: ERROR
\n
"
);
}
else
if
(
nh
->
nlmsg_type
==
NLMSG_ERROR
)
{
continue
;
}
/* Ignore les messages venant de babel */
if
(
nh
->
nlmsg_pid
==
nl_command
.
sockaddr
.
nl_pid
)
continue
;
...
...
@@ -410,10 +399,10 @@ netlink_listen(int (*monitor)(struct nlmsghdr *nh, void *data), void *data) {
if
(
err
<
0
)
return
err
;
interesting
=
interesting
||
err
;
}
}
if
(
msg
.
msg_flags
&
MSG_TRUNC
)
{
fprintf
(
stderr
,
"
netlink_listen: M
essage truncated
\n
"
);
fprintf
(
stderr
,
"
Netlink m
essage truncated
\n
"
);
}
return
interesting
;
}
...
...
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