[ovs-dev] [patch_v6 2/8] dpdk: Parse NAT netlink for userspace datapath.

Ben Pfaff blp at ovn.org
Wed Mar 8 21:54:34 UTC 2017


On Thu, Feb 16, 2017 at 12:47:33AM -0800, Darrell Ball wrote:
> Signed-off-by: Darrell Ball <dlu998 at gmail.com>

Here are some proposed changes as an incremental diff:

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 61704419f962..a7407e65958d 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -5168,14 +5168,14 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
                         break;
                     case OVS_NAT_ATTR_IP_MIN:
                         memcpy(&nat_action_info.min_addr,
-                           (char *) b_nest + NLA_HDRLEN,
-                           b_nest->nla_len - NLA_HDRLEN);
+                               nl_attr_get(b_nest),
+                               nl_attr_get_size(b_nest));
                         ip_min_specified = true;
                         break;
                     case OVS_NAT_ATTR_IP_MAX:
                         memcpy(&nat_action_info.max_addr,
-                            (char *) b_nest + NLA_HDRLEN,
-                             b_nest->nla_len - NLA_HDRLEN);
+                               nl_attr_get(b_nest),
+                               nl_attr_get_size(b_nest));
                         ip_max_specified = true;
                         break;
                     case OVS_NAT_ATTR_PROTO_MIN:
@@ -5197,9 +5197,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
                 }
 
                 if (ip_min_specified && !ip_max_specified) {
-                    memcpy(&nat_action_info.max_addr,
-                           &nat_action_info.min_addr,
-                           sizeof(nat_action_info.max_addr));
+                    nat_action_info.max_addr = nat_action_info.min_addr;
                 }
                 if (proto_num_min_specified && !proto_num_max_specified) {
                     nat_action_info.max_port = nat_action_info.min_port;
@@ -5221,7 +5219,8 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
         }
 
         if (nat_config && !commit) {
-            VLOG_WARN("NAT specified without commit.");
+            static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
+            VLOG_WARN_RL(&rl, "NAT specified without commit.");
         }
 
         conntrack_execute(&dp->conntrack, packets_, aux->flow->dl_type, commit,


More information about the dev mailing list