git://git.onelab.eu
/
iproute2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sync to iproute2-2.6.16-060323
[iproute2.git]
/
ip
/
iprule.c
diff --git
a/ip/iprule.c
b/ip/iprule.c
index
764edc8
..
ccf699f
100644
(file)
--- a/
ip/iprule.c
+++ b/
ip/iprule.c
@@
-28,6
+28,8
@@
#include "rt_names.h"
#include "utils.h"
#include "rt_names.h"
#include "utils.h"
+extern struct rtnl_handle rth;
+
static void usage(void) __attribute__((noreturn));
static void usage(void)
static void usage(void) __attribute__((noreturn));
static void usage(void)
@@
-161,7
+163,6
@@
static int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n,
static int iprule_list(int argc, char **argv)
{
static int iprule_list(int argc, char **argv)
{
- struct rtnl_handle rth;
int af = preferred_family;
if (af == AF_UNSPEC)
int af = preferred_family;
if (af == AF_UNSPEC)
@@
-172,9
+173,6
@@
static int iprule_list(int argc, char **argv)
return -1;
}
return -1;
}
- if (rtnl_open(&rth, 0) < 0)
- return 1;
-
if (rtnl_wilddump_request(&rth, af, RTM_GETRULE) < 0) {
perror("Cannot send dump request");
return 1;
if (rtnl_wilddump_request(&rth, af, RTM_GETRULE) < 0) {
perror("Cannot send dump request");
return 1;
@@
-192,7
+190,6
@@
static int iprule_list(int argc, char **argv)
static int iprule_modify(int cmd, int argc, char **argv)
{
int table_ok = 0;
static int iprule_modify(int cmd, int argc, char **argv)
{
int table_ok = 0;
- struct rtnl_handle rth;
struct {
struct nlmsghdr n;
struct rtmsg r;
struct {
struct nlmsghdr n;
struct rtmsg r;
@@
-256,7
+253,7
@@
static int iprule_modify(int cmd, int argc, char **argv)
addattr32(&req.n, sizeof(req), RTA_FLOW, realm);
} else if (matches(*argv, "table") == 0 ||
strcmp(*argv, "lookup") == 0) {
addattr32(&req.n, sizeof(req), RTA_FLOW, realm);
} else if (matches(*argv, "table") == 0 ||
strcmp(*argv, "lookup") == 0) {
-
int
tid;
+
__u32
tid;
NEXT_ARG();
if (rtnl_rttable_a2n(&tid, *argv))
invarg("invalid table ID\n", *argv);
NEXT_ARG();
if (rtnl_rttable_a2n(&tid, *argv))
invarg("invalid table ID\n", *argv);
@@
-294,9
+291,6
@@
static int iprule_modify(int cmd, int argc, char **argv)
if (!table_ok && cmd == RTM_NEWRULE)
req.r.rtm_table = RT_TABLE_MAIN;
if (!table_ok && cmd == RTM_NEWRULE)
req.r.rtm_table = RT_TABLE_MAIN;
- if (rtnl_open(&rth, 0) < 0)
- return 1;
-
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
return 2;
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
return 2;
@@
-306,7
+300,7
@@
static int iprule_modify(int cmd, int argc, char **argv)
static int flush_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
{
static int flush_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
{
- struct rtnl_handle rth;
+ struct rtnl_handle rth
2
;
struct rtmsg *r = NLMSG_DATA(n);
int len = n->nlmsg_len;
struct rtattr * tb[RTA_MAX+1];
struct rtmsg *r = NLMSG_DATA(n);
int len = n->nlmsg_len;
struct rtattr * tb[RTA_MAX+1];
@@
-321,11
+315,13
@@
static int flush_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *a
n->nlmsg_type = RTM_DELRULE;
n->nlmsg_flags = NLM_F_REQUEST;
n->nlmsg_type = RTM_DELRULE;
n->nlmsg_flags = NLM_F_REQUEST;
- if (rtnl_open(&rth, 0) < 0)
+ if (rtnl_open(&rth
2
, 0) < 0)
return -1;
return -1;
- if (rtnl_talk(&rth, n, 0, 0, NULL, NULL, NULL) < 0)
+ if (rtnl_talk(&rth
2
, n, 0, 0, NULL, NULL, NULL) < 0)
return -2;
return -2;
+
+ rtnl_close(&rth2);
}
return 0;
}
return 0;
@@
-333,20
+329,16
@@
static int flush_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *a
static int iprule_flush(int argc, char **argv)
{
static int iprule_flush(int argc, char **argv)
{
- struct rtnl_handle rth;
int af = preferred_family;
if (af == AF_UNSPEC)
af = AF_INET;
if (argc > 0) {
int af = preferred_family;
if (af == AF_UNSPEC)
af = AF_INET;
if (argc > 0) {
- fprintf(stderr, "\"ip rule flush\"
need not any arguments.
\n");
+ fprintf(stderr, "\"ip rule flush\"
does not allow arguments
\n");
return -1;
}
return -1;
}
- if (rtnl_open(&rth, 0) < 0)
- return 1;
-
if (rtnl_wilddump_request(&rth, af, RTM_GETRULE) < 0) {
perror("Cannot send dump request");
return 1;
if (rtnl_wilddump_request(&rth, af, RTM_GETRULE) < 0) {
perror("Cannot send dump request");
return 1;