Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iproute2
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
iproute2
Commits
8ed63ab1
Commit
8ed63ab1
authored
Sep 21, 2005
by
shemminger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix leaks and warnings reported by valgrind.
parent
fc57a9df
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
38 deletions
+51
-38
ChangeLog
ChangeLog
+5
-0
ip/ip.c
ip/ip.c
+2
-0
ip/ipaddress.c
ip/ipaddress.c
+4
-2
lib/libnetlink.c
lib/libnetlink.c
+38
-36
tc/tc.c
tc/tc.c
+2
-0
No files found.
ChangeLog
View file @
8ed63ab1
2005-09-21 Stephen Hemminger <shemminger@localhost.localdomain>
* Fix uninitialized memory and leaks with valgrind
Reported by Redhat
2005-09-01 Mike Frysinger <vapier@gentoo.org>
2005-09-01 Mike Frysinger <vapier@gentoo.org>
* Fix build issues with netem tables (parallel make and HOSTCC)
* Fix build issues with netem tables (parallel make and HOSTCC)
...
...
ip/ip.c
View file @
8ed63ab1
...
@@ -122,6 +122,8 @@ static int batch(const char *name)
...
@@ -122,6 +122,8 @@ static int batch(const char *name)
break
;
break
;
}
}
}
}
if
(
line
)
free
(
line
);
rtnl_close
(
&
rth
);
rtnl_close
(
&
rth
);
return
ret
;
return
ret
;
...
...
ip/ipaddress.c
View file @
8ed63ab1
...
@@ -494,7 +494,7 @@ int ipaddr_list_or_flush(int argc, char **argv, int flush)
...
@@ -494,7 +494,7 @@ int ipaddr_list_or_flush(int argc, char **argv, int flush)
{
{
struct
nlmsg_list
*
linfo
=
NULL
;
struct
nlmsg_list
*
linfo
=
NULL
;
struct
nlmsg_list
*
ainfo
=
NULL
;
struct
nlmsg_list
*
ainfo
=
NULL
;
struct
nlmsg_list
*
l
;
struct
nlmsg_list
*
l
,
*
n
;
char
*
filter_dev
=
NULL
;
char
*
filter_dev
=
NULL
;
int
no_link
=
0
;
int
no_link
=
0
;
...
@@ -695,13 +695,15 @@ int ipaddr_list_or_flush(int argc, char **argv, int flush)
...
@@ -695,13 +695,15 @@ int ipaddr_list_or_flush(int argc, char **argv, int flush)
}
}
}
}
for
(
l
=
linfo
;
l
;
l
=
l
->
next
)
{
for
(
l
=
linfo
;
l
;
l
=
n
)
{
n
=
l
->
next
;
if
(
no_link
||
print_linkinfo
(
NULL
,
&
l
->
h
,
stdout
)
==
0
)
{
if
(
no_link
||
print_linkinfo
(
NULL
,
&
l
->
h
,
stdout
)
==
0
)
{
struct
ifinfomsg
*
ifi
=
NLMSG_DATA
(
&
l
->
h
);
struct
ifinfomsg
*
ifi
=
NLMSG_DATA
(
&
l
->
h
);
if
(
filter
.
family
!=
AF_PACKET
)
if
(
filter
.
family
!=
AF_PACKET
)
print_selected_addrinfo
(
ifi
->
ifi_index
,
ainfo
,
stdout
);
print_selected_addrinfo
(
ifi
->
ifi_index
,
ainfo
,
stdout
);
}
}
fflush
(
stdout
);
fflush
(
stdout
);
free
(
l
);
}
}
return
0
;
return
0
;
...
...
lib/libnetlink.c
View file @
8ed63ab1
...
@@ -30,7 +30,8 @@ void rtnl_close(struct rtnl_handle *rth)
...
@@ -30,7 +30,8 @@ void rtnl_close(struct rtnl_handle *rth)
close
(
rth
->
fd
);
close
(
rth
->
fd
);
}
}
int
rtnl_open_byproto
(
struct
rtnl_handle
*
rth
,
unsigned
subscriptions
,
int
protocol
)
int
rtnl_open_byproto
(
struct
rtnl_handle
*
rth
,
unsigned
subscriptions
,
int
protocol
)
{
{
socklen_t
addr_len
;
socklen_t
addr_len
;
int
sndbuf
=
32768
;
int
sndbuf
=
32768
;
...
@@ -95,6 +96,7 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
...
@@ -95,6 +96,7 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
memset
(
&
nladdr
,
0
,
sizeof
(
nladdr
));
memset
(
&
nladdr
,
0
,
sizeof
(
nladdr
));
nladdr
.
nl_family
=
AF_NETLINK
;
nladdr
.
nl_family
=
AF_NETLINK
;
memset
(
&
req
,
0
,
sizeof
(
req
));
req
.
nlh
.
nlmsg_len
=
sizeof
(
req
);
req
.
nlh
.
nlmsg_len
=
sizeof
(
req
);
req
.
nlh
.
nlmsg_type
=
type
;
req
.
nlh
.
nlmsg_type
=
type
;
req
.
nlh
.
nlmsg_flags
=
NLM_F_ROOT
|
NLM_F_MATCH
|
NLM_F_REQUEST
;
req
.
nlh
.
nlmsg_flags
=
NLM_F_ROOT
|
NLM_F_MATCH
|
NLM_F_REQUEST
;
...
@@ -102,7 +104,8 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
...
@@ -102,7 +104,8 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
req
.
nlh
.
nlmsg_seq
=
rth
->
dump
=
++
rth
->
seq
;
req
.
nlh
.
nlmsg_seq
=
rth
->
dump
=
++
rth
->
seq
;
req
.
g
.
rtgen_family
=
family
;
req
.
g
.
rtgen_family
=
family
;
return
sendto
(
rth
->
fd
,
(
void
*
)
&
req
,
sizeof
(
req
),
0
,
(
struct
sockaddr
*
)
&
nladdr
,
sizeof
(
nladdr
));
return
sendto
(
rth
->
fd
,
(
void
*
)
&
req
,
sizeof
(
req
),
0
,
(
struct
sockaddr
*
)
&
nladdr
,
sizeof
(
nladdr
));
}
}
int
rtnl_send
(
struct
rtnl_handle
*
rth
,
const
char
*
buf
,
int
len
)
int
rtnl_send
(
struct
rtnl_handle
*
rth
,
const
char
*
buf
,
int
len
)
...
@@ -119,12 +122,15 @@ int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)
...
@@ -119,12 +122,15 @@ int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len)
{
{
struct
nlmsghdr
nlh
;
struct
nlmsghdr
nlh
;
struct
sockaddr_nl
nladdr
;
struct
sockaddr_nl
nladdr
;
struct
iovec
iov
[
2
]
=
{
{
&
nlh
,
sizeof
(
nlh
)
},
{
req
,
len
}
};
struct
iovec
iov
[
2
]
=
{
{
.
iov_base
=
&
nlh
,
.
iov_len
=
sizeof
(
nlh
)
},
{
.
iov_base
=
req
,
.
iov_len
=
len
}
};
struct
msghdr
msg
=
{
struct
msghdr
msg
=
{
(
void
*
)
&
nladdr
,
sizeof
(
nladdr
)
,
.
msg_name
=
&
nladdr
,
iov
,
2
,
.
msg_namelen
=
sizeof
(
nladdr
)
,
NULL
,
0
,
.
msg_iov
=
iov
,
0
.
msg_iovlen
=
2
,
};
};
memset
(
&
nladdr
,
0
,
sizeof
(
nladdr
));
memset
(
&
nladdr
,
0
,
sizeof
(
nladdr
));
...
@@ -145,21 +151,22 @@ int rtnl_dump_filter(struct rtnl_handle *rth,
...
@@ -145,21 +151,22 @@ int rtnl_dump_filter(struct rtnl_handle *rth,
rtnl_filter_t
junk
,
rtnl_filter_t
junk
,
void
*
arg2
)
void
*
arg2
)
{
{
char
buf
[
16384
];
struct
sockaddr_nl
nladdr
;
struct
sockaddr_nl
nladdr
;
struct
iovec
iov
=
{
buf
,
sizeof
(
buf
)
};
struct
iovec
iov
;
struct
msghdr
msg
=
{
.
msg_name
=
&
nladdr
,
.
msg_namelen
=
sizeof
(
nladdr
),
.
msg_iov
=
&
iov
,
.
msg_iovlen
=
1
,
};
char
buf
[
16384
];
iov
.
iov_base
=
buf
;
while
(
1
)
{
while
(
1
)
{
int
status
;
int
status
;
struct
nlmsghdr
*
h
;
struct
nlmsghdr
*
h
;
struct
msghdr
msg
=
{
iov
.
iov_len
=
sizeof
(
buf
);
(
void
*
)
&
nladdr
,
sizeof
(
nladdr
),
&
iov
,
1
,
NULL
,
0
,
0
};
status
=
recvmsg
(
rth
->
fd
,
&
msg
,
0
);
status
=
recvmsg
(
rth
->
fd
,
&
msg
,
0
);
if
(
status
<
0
)
{
if
(
status
<
0
)
{
...
@@ -168,14 +175,11 @@ int rtnl_dump_filter(struct rtnl_handle *rth,
...
@@ -168,14 +175,11 @@ int rtnl_dump_filter(struct rtnl_handle *rth,
perror
(
"OVERRUN"
);
perror
(
"OVERRUN"
);
continue
;
continue
;
}
}
if
(
status
==
0
)
{
if
(
status
==
0
)
{
fprintf
(
stderr
,
"EOF on netlink
\n
"
);
fprintf
(
stderr
,
"EOF on netlink
\n
"
);
return
-
1
;
return
-
1
;
}
}
if
(
msg
.
msg_namelen
!=
sizeof
(
nladdr
))
{
fprintf
(
stderr
,
"sender address length == %d
\n
"
,
msg
.
msg_namelen
);
exit
(
1
);
}
h
=
(
struct
nlmsghdr
*
)
buf
;
h
=
(
struct
nlmsghdr
*
)
buf
;
while
(
NLMSG_OK
(
h
,
status
))
{
while
(
NLMSG_OK
(
h
,
status
))
{
...
@@ -231,14 +235,14 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
...
@@ -231,14 +235,14 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
unsigned
seq
;
unsigned
seq
;
struct
nlmsghdr
*
h
;
struct
nlmsghdr
*
h
;
struct
sockaddr_nl
nladdr
;
struct
sockaddr_nl
nladdr
;
struct
iovec
iov
=
{
(
void
*
)
n
,
n
->
nlmsg_len
};
struct
iovec
iov
;
char
buf
[
16384
];
struct
msghdr
msg
=
{
struct
msghdr
msg
=
{
(
void
*
)
&
nladdr
,
sizeof
(
nladdr
)
,
.
msg_name
=
&
nladdr
,
&
iov
,
1
,
.
msg_namelen
=
sizeof
(
nladdr
)
,
NULL
,
0
,
.
msg_iov
=
&
iov
,
0
.
msg_iovlen
=
1
,
};
};
char
buf
[
16384
];
memset
(
&
nladdr
,
0
,
sizeof
(
nladdr
));
memset
(
&
nladdr
,
0
,
sizeof
(
nladdr
));
nladdr
.
nl_family
=
AF_NETLINK
;
nladdr
.
nl_family
=
AF_NETLINK
;
...
@@ -340,7 +344,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
...
@@ -340,7 +344,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
}
}
}
}
int
rtnl_listen
(
struct
rtnl_handle
*
rtnl
,
int
rtnl_listen
(
struct
rtnl_handle
*
rtnl
,
rtnl_filter_t
handler
,
rtnl_filter_t
handler
,
void
*
jarg
)
void
*
jarg
)
{
{
...
@@ -348,22 +352,20 @@ int rtnl_listen(struct rtnl_handle *rtnl,
...
@@ -348,22 +352,20 @@ int rtnl_listen(struct rtnl_handle *rtnl,
struct
nlmsghdr
*
h
;
struct
nlmsghdr
*
h
;
struct
sockaddr_nl
nladdr
;
struct
sockaddr_nl
nladdr
;
struct
iovec
iov
;
struct
iovec
iov
;
char
buf
[
8192
];
struct
msghdr
msg
=
{
struct
msghdr
msg
=
{
(
void
*
)
&
nladdr
,
sizeof
(
nladdr
)
,
.
msg_name
=
&
nladdr
,
&
iov
,
1
,
.
msg_namelen
=
sizeof
(
nladdr
)
,
NULL
,
0
,
.
msg_iov
=
&
iov
,
0
.
msg_iovlen
=
1
,
};
};
char
buf
[
8192
];
memset
(
&
nladdr
,
0
,
sizeof
(
nladdr
));
memset
(
&
nladdr
,
0
,
sizeof
(
nladdr
));
nladdr
.
nl_family
=
AF_NETLINK
;
nladdr
.
nl_family
=
AF_NETLINK
;
nladdr
.
nl_pid
=
0
;
nladdr
.
nl_pid
=
0
;
nladdr
.
nl_groups
=
0
;
nladdr
.
nl_groups
=
0
;
iov
.
iov_base
=
buf
;
iov
.
iov_base
=
buf
;
while
(
1
)
{
while
(
1
)
{
iov
.
iov_len
=
sizeof
(
buf
);
iov
.
iov_len
=
sizeof
(
buf
);
status
=
recvmsg
(
rtnl
->
fd
,
&
msg
,
0
);
status
=
recvmsg
(
rtnl
->
fd
,
&
msg
,
0
);
...
@@ -485,7 +487,7 @@ int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data)
...
@@ -485,7 +487,7 @@ int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data)
return
0
;
return
0
;
}
}
int
addattr_l
(
struct
nlmsghdr
*
n
,
int
maxlen
,
int
type
,
const
void
*
data
,
int
addattr_l
(
struct
nlmsghdr
*
n
,
int
maxlen
,
int
type
,
const
void
*
data
,
int
alen
)
int
alen
)
{
{
int
len
=
RTA_LENGTH
(
alen
);
int
len
=
RTA_LENGTH
(
alen
);
...
@@ -533,7 +535,7 @@ int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data)
...
@@ -533,7 +535,7 @@ int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data)
return
0
;
return
0
;
}
}
int
rta_addattr_l
(
struct
rtattr
*
rta
,
int
maxlen
,
int
type
,
int
rta_addattr_l
(
struct
rtattr
*
rta
,
int
maxlen
,
int
type
,
const
void
*
data
,
int
alen
)
const
void
*
data
,
int
alen
)
{
{
struct
rtattr
*
subrta
;
struct
rtattr
*
subrta
;
...
...
tc/tc.c
View file @
8ed63ab1
...
@@ -246,6 +246,8 @@ static int batch(const char *name)
...
@@ -246,6 +246,8 @@ static int batch(const char *name)
break
;
break
;
}
}
}
}
if
(
line
)
free
(
line
);
rtnl_close
(
&
rth
);
rtnl_close
(
&
rth
);
return
ret
;
return
ret
;
...
...
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