diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2010-05-09 20:17:54 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2010-05-09 20:17:54 +0200 |
commit | a5f25889216411ad7492047fafe6de03b8408440 (patch) | |
tree | 3716ffb20863ecfd4edaf4ff33298c3e88bd1e42 /examples | |
parent | cbded627a15baf792465c0cbe960b36cb9408fe2 (diff) | |
download | libmnl-a5f25889216411ad7492047fafe6de03b8408440.tar.gz libmnl-a5f25889216411ad7492047fafe6de03b8408440.zip |
relax mnl_attr_type_valid() checkings and change errno value
This patch relaxes strict attribute checkings in the example files.
I have also changed the errno value, now it's EOPNOTSUPP instead of
EINVAL.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/genl-family-get.c | 19 | ||||
-rw-r--r-- | examples/nf-queue.c | 8 | ||||
-rw-r--r-- | examples/rtnl-link-dump.c | 7 | ||||
-rw-r--r-- | examples/rtnl-link-dump2.c | 7 | ||||
-rw-r--r-- | examples/rtnl-link-dump3.c | 8 | ||||
-rw-r--r-- | examples/rtnl-link-event.c | 7 | ||||
-rw-r--r-- | examples/rtnl-route-dump.c | 15 |
7 files changed, 31 insertions, 40 deletions
diff --git a/examples/genl-family-get.c b/examples/genl-family-get.c index 7b9acfa..326755e 100644 --- a/examples/genl-family-get.c +++ b/examples/genl-family-get.c @@ -17,10 +17,9 @@ static int parse_mc_grps_cb(const struct nlattr *attr, void *data) const struct nlattr **tb = (const struct nlattr **)data; int type = mnl_attr_get_type(attr); - if (mnl_attr_type_valid(attr, CTRL_ATTR_MCAST_GRP_MAX) < 0) { - perror("mnl_attr_type_valid"); - return MNL_CB_ERROR; - } + /* skip unsupported attribute in user-space */ + if (mnl_attr_type_valid(attr, CTRL_ATTR_MCAST_GRP_MAX) < 0) + return MNL_CB_OK; switch(type) { case CTRL_ATTR_MCAST_GRP_ID: @@ -65,10 +64,8 @@ static int parse_family_ops_cb(const struct nlattr *attr, void *data) const struct nlattr **tb = (const struct nlattr **)data; int type = mnl_attr_get_type(attr); - if (mnl_attr_type_valid(attr, CTRL_ATTR_OP_MAX) < 0) { - perror("mnl_attr_type_valid"); - return MNL_CB_ERROR; - } + if (mnl_attr_type_valid(attr, CTRL_ATTR_OP_MAX) < 0) + return MNL_CB_OK; switch(type) { case CTRL_ATTR_OP_ID: @@ -110,10 +107,8 @@ static int data_attr_cb(const struct nlattr *attr, void *data) const struct nlattr **tb = (const struct nlattr **)data; int type = mnl_attr_get_type(attr); - if (mnl_attr_type_valid(attr, CTRL_ATTR_MAX) < 0) { - perror("mnl_attr_type_valid"); - return MNL_CB_ERROR; - } + if (mnl_attr_type_valid(attr, CTRL_ATTR_MAX) < 0) + return MNL_CB_OK; switch(type) { case CTRL_ATTR_FAMILY_NAME: diff --git a/examples/nf-queue.c b/examples/nf-queue.c index bde9db1..1df004a 100644 --- a/examples/nf-queue.c +++ b/examples/nf-queue.c @@ -26,10 +26,10 @@ static int parse_attr_cb(const struct nlattr *attr, void *data) const struct nlattr **tb = (const struct nlattr **)data; int type = mnl_attr_get_type(attr); - if (mnl_attr_type_valid(attr, NFQA_MAX) < 0) { - perror("mnl_attr_type_valid"); - return MNL_CB_ERROR; - } + /* skip unsupported attribute in user-space */ + if (mnl_attr_type_valid(attr, NFQA_MAX) < 0) + return MNL_CB_OK; + switch(type) { case NFQA_MARK: case NFQA_IFINDEX_INDEV: diff --git a/examples/rtnl-link-dump.c b/examples/rtnl-link-dump.c index 4bbc997..8bce803 100644 --- a/examples/rtnl-link-dump.c +++ b/examples/rtnl-link-dump.c @@ -19,10 +19,9 @@ static int data_attr_cb(const struct nlattr *attr, void *data) const struct nlattr **tb = (const struct nlattr **)data; int type = mnl_attr_get_type(attr); - if (mnl_attr_type_valid(attr, IFLA_MAX) < 0) { - perror("mnl_attr_type_valid"); - return MNL_CB_ERROR; - } + /* skip unsupported attribute in user-space */ + if (mnl_attr_type_valid(attr, IFLA_MAX) < 0) + return MNL_CB_OK; switch(type) { case IFLA_MTU: diff --git a/examples/rtnl-link-dump2.c b/examples/rtnl-link-dump2.c index 7162ab9..ac3a6be 100644 --- a/examples/rtnl-link-dump2.c +++ b/examples/rtnl-link-dump2.c @@ -16,10 +16,9 @@ static int data_attr_cb(const struct nlattr *attr, void *data) { - if (mnl_attr_type_valid(attr, IFLA_MAX) < 0) { - perror("mnl_attr_type_valid"); - return MNL_CB_ERROR; - } + /* skip unsupported attribute in user-space */ + if (mnl_attr_type_valid(attr, IFLA_MAX) < 0) + return MNL_CB_OK; switch(mnl_attr_get_type(attr)) { case IFLA_MTU: diff --git a/examples/rtnl-link-dump3.c b/examples/rtnl-link-dump3.c index 07acfbd..3c1473e 100644 --- a/examples/rtnl-link-dump3.c +++ b/examples/rtnl-link-dump3.c @@ -31,10 +31,10 @@ static int data_cb(const struct nlmsghdr *nlh, void *data) mnl_attr_for_each(attr, nlh, sizeof(*ifm)) { int type = mnl_attr_get_type(attr); - if (mnl_attr_type_valid(attr, IFLA_MAX) < 0) { - perror("mnl_attr_type_valid"); - return MNL_CB_ERROR; - } + /* skip unsupported attribute in user-space */ + if (mnl_attr_type_valid(attr, IFLA_MAX) < 0) + return MNL_CB_OK; + switch(type) { case IFLA_MTU: if (mnl_attr_validate(attr, MNL_TYPE_U32) < 0) { diff --git a/examples/rtnl-link-event.c b/examples/rtnl-link-event.c index b0bd5dc..aa51a1e 100644 --- a/examples/rtnl-link-event.c +++ b/examples/rtnl-link-event.c @@ -18,10 +18,9 @@ static int data_attr_cb(const struct nlattr *attr, void *data) const struct nlattr **tb = (const struct nlattr **)data; int type = mnl_attr_get_type(attr); - if (mnl_attr_type_valid(attr, IFLA_MAX) < 0) { - perror("mnl_attr_type_valid"); - return MNL_CB_ERROR; - } + /* skip unsupported attribute in user-space */ + if (mnl_attr_type_valid(attr, IFLA_MAX) < 0) + return MNL_CB_OK; switch(type) { case IFLA_MTU: diff --git a/examples/rtnl-route-dump.c b/examples/rtnl-route-dump.c index bc038cd..34c95cf 100644 --- a/examples/rtnl-route-dump.c +++ b/examples/rtnl-route-dump.c @@ -17,10 +17,10 @@ static int data_attr_cb2(const struct nlattr *attr, void *data) { - if (mnl_attr_type_valid(attr, RTAX_MAX) < 0) { - perror("mnl_attr_type_valid"); - return MNL_CB_ERROR; - } + /* skip unsupported attribute in user-space */ + if (mnl_attr_type_valid(attr, RTAX_MAX) < 0) + return MNL_CB_OK; + if (mnl_attr_validate(attr, MNL_TYPE_U32) < 0) { perror("mnl_attr_validate"); return MNL_CB_ERROR; @@ -76,10 +76,9 @@ static int data_attr_cb(const struct nlattr *attr, void *data) const struct nlattr **tb = (const struct nlattr **)data; int type = mnl_attr_get_type(attr); - if (mnl_attr_type_valid(attr, RTA_MAX) < 0) { - perror("mnl_attr_type_valid"); - return MNL_CB_ERROR; - } + /* skip unsupported attribute in user-space */ + if (mnl_attr_type_valid(attr, RTA_MAX) < 0) + return MNL_CB_OK; switch(type) { case RTA_TABLE: |