diff options
author | Paul Blakey <paulb@mellanox.com> | 2017-06-13 18:03:43 +0300 |
---|---|---|
committer | Simon Horman <simon.horman@netronome.com> | 2017-06-15 11:49:26 +0200 |
commit | 6c343984809c1e02c3e86991a71755705950d405 (patch) | |
tree | 244b37af6270a4931a8e73f70db9ae943f48b813 /lib/dpif-netlink.c | |
parent | 30b6b047260bb64281f9db802ec7a2a5196e088a (diff) | |
download | openvswitch-6c343984809c1e02c3e86991a71755705950d405.tar.gz |
dpif-netlink: Use netdev flow get api to query a flow
Search all datapath added netdevs for a given flow
using netdev flow api and parse it back to dpif flow.
Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Diffstat (limited to 'lib/dpif-netlink.c')
-rw-r--r-- | lib/dpif-netlink.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index 376707785..20e49f9fc 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -1989,6 +1989,45 @@ dpif_netlink_operate__(struct dpif_netlink *dpif, } static int +parse_flow_get(struct dpif_netlink *dpif, struct dpif_flow_get *get) +{ + struct dpif_flow *dpif_flow = get->flow; + struct match match; + struct nlattr *actions; + struct dpif_flow_stats stats; + struct ofpbuf buf; + uint64_t act_buf[1024 / 8]; + struct odputil_keybuf maskbuf; + struct odputil_keybuf keybuf; + struct odputil_keybuf actbuf; + struct ofpbuf key, mask, act; + int err; + + ofpbuf_use_stack(&buf, &act_buf, sizeof act_buf); + err = netdev_ports_flow_get(DPIF_HMAP_KEY(&dpif->dpif), &match, + &actions, get->ufid, &stats, &buf); + if (err) { + return err; + } + + VLOG_DBG("found flow from netdev, translating to dpif flow"); + + ofpbuf_use_stack(&key, &keybuf, sizeof keybuf); + ofpbuf_use_stack(&act, &actbuf, sizeof actbuf); + ofpbuf_use_stack(&mask, &maskbuf, sizeof maskbuf); + dpif_netlink_netdev_match_to_dpif_flow(&match, &key, &mask, actions, + &stats, + (ovs_u128 *) get->ufid, + dpif_flow, + false); + ofpbuf_put(get->buffer, nl_attr_get(actions), nl_attr_get_size(actions)); + dpif_flow->actions = ofpbuf_at(get->buffer, 0, 0); + dpif_flow->actions_len = nl_attr_get_size(actions); + + return 0; +} + +static int parse_flow_put(struct dpif_netlink *dpif, struct dpif_flow_put *put) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); @@ -2160,7 +2199,17 @@ try_send_to_netdev(struct dpif_netlink *dpif, struct dpif_op *op) del->stats); break; } - case DPIF_OP_FLOW_GET: + case DPIF_OP_FLOW_GET: { + struct dpif_flow_get *get = &op->u.flow_get; + + if (!op->u.flow_get.ufid) { + break; + } + dbg_print_flow(get->key, get->key_len, NULL, 0, NULL, 0, + get->ufid, "GET"); + err = parse_flow_get(dpif, get); + break; + } case DPIF_OP_EXECUTE: default: break; |