From: Wei Yongjun <yongjun_...@trendmicro.com.cn>

Using nla_for_each_nested() or nla_for_each_attr()
to simplify the code.

dpatch engine is used to auto generate this patch.
(https://github.com/weiyj/dpatch)

Signed-off-by: Wei Yongjun <yongjun_...@trendmicro.com.cn>
---
 net/openvswitch/actions.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 0811447..b67594f 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -288,8 +288,7 @@ static int output_userspace(struct datapath *dp, struct 
sk_buff *skb,
        upcall.userdata = NULL;
        upcall.portid = 0;
 
-       for (a = nla_data(attr), rem = nla_len(attr); rem > 0;
-                a = nla_next(a, &rem)) {
+       nla_for_each_nested(a, attr, rem) {
                switch (nla_type(a)) {
                case OVS_USERSPACE_ATTR_USERDATA:
                        upcall.userdata = a;
@@ -311,8 +310,7 @@ static int sample(struct datapath *dp, struct sk_buff *skb,
        const struct nlattr *a;
        int rem;
 
-       for (a = nla_data(attr), rem = nla_len(attr); rem > 0;
-                a = nla_next(a, &rem)) {
+       nla_for_each_nested(a, attr, rem) {
                switch (nla_type(a)) {
                case OVS_SAMPLE_ATTR_PROBABILITY:
                        if (net_random() >= nla_get_u32(a))
@@ -371,8 +369,7 @@ static int do_execute_actions(struct datapath *dp, struct 
sk_buff *skb,
        const struct nlattr *a;
        int rem;
 
-       for (a = attr, rem = len; rem > 0;
-            a = nla_next(a, &rem)) {
+       nla_for_each_attr(a, attr, len, rem) {
                int err = 0;
 
                if (prev_port != -1) {


_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to