From patchwork Fri Nov 20 10:28:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Shanmugam X-Patchwork-Id: 546875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id 94148140134 for ; Fri, 20 Nov 2015 21:28:18 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 2A01E10700; Fri, 20 Nov 2015 02:28:12 -0800 (PST) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 18617106F9 for ; Fri, 20 Nov 2015 02:28:11 -0800 (PST) Received: from bar4.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id A12B41621AC for ; Fri, 20 Nov 2015 03:28:10 -0700 (MST) X-ASG-Debug-ID: 1448015289-03dc2178da2b240001-byXFYA Received: from mx3-pf2.cudamail.com ([192.168.14.1]) by bar4.cudamail.com with ESMTP id YYLmUjUljJuTZxx8 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 20 Nov 2015 03:28:10 -0700 (MST) X-Barracuda-Envelope-From: bschanmu@redhat.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.1 Received: from unknown (HELO mx1.redhat.com) (209.132.183.28) by mx3-pf2.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 20 Nov 2015 10:28:09 -0000 Received-SPF: pass (mx3-pf2.cudamail.com: SPF record at _spf1.redhat.com designates 209.132.183.28 as permitted sender) X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-Barracuda-RBL-IP: 209.132.183.28 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 01C4D4AD68 for ; Fri, 20 Nov 2015 10:28:08 +0000 (UTC) Received: from anbu-ltp.redhat.com (ovpn-113-56.phx2.redhat.com [10.3.113.56]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAKAS0fu031473; Fri, 20 Nov 2015 05:28:07 -0500 X-CudaMail-Envelope-Sender: bschanmu@redhat.com From: bschanmu@redhat.com To: dev@openvswitch.org X-CudaMail-MID: CM-V2-1119003108 X-CudaMail-DTE: 112015 X-CudaMail-Originating-IP: 209.132.183.28 Date: Fri, 20 Nov 2015 15:58:00 +0530 X-ASG-Orig-Subj: [##CM-V2-1119003108##][PATCH v3 2/4] ovn: New flows for DHCP tranffic Message-Id: <1448015281-29624-3-git-send-email-bschanmu@redhat.com> In-Reply-To: <1448015281-29624-1-git-send-email-bschanmu@redhat.com> References: <1448015281-29624-1-git-send-email-bschanmu@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-GBUdb-Analysis: 0, 209.132.183.28, Ugly c=0.165853 p=-0.2 Source Normal X-MessageSniffer-Rules: 0-0-0-12295-c X-Barracuda-Connect: UNKNOWN[192.168.14.1] X-Barracuda-Start-Time: 1448015290 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using per-user scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, NO_REAL_NAME, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.24562 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 NO_REAL_NAME From: does not include a real name 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Subject: [ovs-dev] [PATCH v3 2/4] ovn: New flows for DHCP tranffic X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" The ovn-controller registers a flow in table 33 (LOCAL_OUTPUT) to send a packet matching the DHCP discover/request structure to a specific controller id, that the ovn pinctrl has registered on it's ofconn. Signed-off-by: Babu Shanmugam --- lib/ofp-util.c | 14 ++++++++++++++ lib/ofp-util.h | 3 +++ ovn/controller/physical.c | 25 +++++++++++++++++++++++-- ovn/controller/pinctrl.c | 7 +++++++ ovn/controller/pinctrl.h | 2 ++ 5 files changed, 49 insertions(+), 2 deletions(-) diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 342be54..7cfa06b 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -1544,6 +1544,20 @@ ofputil_make_set_packet_in_format(enum ofp_version ofp_version, return msg; } +struct ofpbuf * +ofputil_make_set_controller_id(enum ofp_version ofp_version, + uint16_t controller_id) +{ + struct nx_controller_id *cid; + struct ofpbuf *msg; + + msg = ofpraw_alloc(OFPRAW_NXT_SET_CONTROLLER_ID, ofp_version, 0); + cid = ofpbuf_put_zeros(msg, sizeof *cid); + cid->controller_id = htons(controller_id); + + return msg; +} + /* Returns an OpenFlow message that can be used to turn the flow_mod_table_id * extension on or off (according to 'flow_mod_table_id'). */ struct ofpbuf * diff --git a/lib/ofp-util.h b/lib/ofp-util.h index 8914342..5373d86 100644 --- a/lib/ofp-util.h +++ b/lib/ofp-util.h @@ -237,6 +237,9 @@ int ofputil_packet_in_format_from_string(const char *); const char *ofputil_packet_in_format_to_string(enum nx_packet_in_format); struct ofpbuf *ofputil_make_set_packet_in_format(enum ofp_version, enum nx_packet_in_format); +struct ofpbuf * +ofputil_make_set_controller_id(enum ofp_version ofp_version, + uint16_t controller_id); /* NXT_FLOW_MOD_TABLE_ID extension. */ struct ofpbuf *ofputil_make_flow_mod_table_id(bool flow_mod_table_id); diff --git a/ovn/controller/physical.c b/ovn/controller/physical.c index 5821c11..16eb7ae 100644 --- a/ovn/controller/physical.c +++ b/ovn/controller/physical.c @@ -18,6 +18,7 @@ #include "lflow.h" #include "match.h" #include "ofctrl.h" +#include "pinctrl.h" #include "ofp-actions.h" #include "ofpbuf.h" #include "ovn-controller.h" @@ -396,17 +397,37 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, tag ? 150 : 100, &match, &ofpacts); } - /* Table 33, priority 100. - * ======================= + /* Table 33, priority 100 and 150 + * ============================== * * Implements output to local hypervisor. Each flow matches a * logical output port on the local hypervisor, and resubmits to * table 34. + * Also, send the DHCP traffic to the controller as packet-in */ match_init_catchall(&match); ofpbuf_clear(&ofpacts); + match_set_metadata(&match, htonll(binding->datapath->tunnel_key)); + match_set_dl_type(&match, htons(ETH_TYPE_IP)); + match_set_nw_proto(&match, IPPROTO_UDP); + match_set_nw_src(&match, htonl(INADDR_ANY)); + match_set_nw_dst(&match, htonl(INADDR_BROADCAST)); + match_set_tp_src(&match, htons(68)); + match_set_tp_dst(&match, htons(67)); + + struct ofpact_controller *controller = + ofpact_put_CONTROLLER(&ofpacts); + controller->max_len = UINT16_MAX; + controller->controller_id = OVN_PACKET_IN_CONTROLLER_ID; + controller->reason = OFPR_ACTION; + ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 150, &match, + &ofpacts); + + match_init_catchall(&match); + ofpbuf_clear(&ofpacts); + /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */ match_set_metadata(&match, htonll(binding->datapath->tunnel_key)); match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c index 1b406aa..3479698 100644 --- a/ovn/controller/pinctrl.c +++ b/ovn/controller/pinctrl.c @@ -82,6 +82,7 @@ process_packet_in(struct controller_ctx *ctx OVS_UNUSED, if (ofputil_decode_packet_in(&pin, msg) != 0) { return; } + if (pin.reason != OFPR_NO_MATCH) { return; } @@ -98,6 +99,7 @@ pinctrl_recv(struct controller_ctx *ctx, const struct ofp_header *oh, } else if (type == OFPTYPE_GET_CONFIG_REPLY) { struct ofpbuf rq_buf; struct ofpbuf *spif; + struct ofpbuf *scid; struct ofp_switch_config *config_, config; ofpbuf_use_const(&rq_buf, oh, ntohs(oh->length)); @@ -105,9 +107,14 @@ pinctrl_recv(struct controller_ctx *ctx, const struct ofp_header *oh, config = *config_; config.miss_send_len = htons(UINT16_MAX); set_switch_config(swconn, &config); + spif = ofputil_make_set_packet_in_format(rconn_get_version(swconn), NXPIF_NXM); queue_msg(spif); + + scid = ofputil_make_set_controller_id(rconn_get_version(swconn), + OVN_PACKET_IN_CONTROLLER_ID); + queue_msg(scid); } else if (type == OFPTYPE_PACKET_IN) { process_packet_in(ctx, oh); } else if (type != OFPTYPE_ECHO_REPLY && type != OFPTYPE_BARRIER_REPLY) { diff --git a/ovn/controller/pinctrl.h b/ovn/controller/pinctrl.h index 65d5dfe..c51e31e 100644 --- a/ovn/controller/pinctrl.h +++ b/ovn/controller/pinctrl.h @@ -21,6 +21,8 @@ #include "meta-flow.h" +#define OVN_PACKET_IN_CONTROLLER_ID (UINT16_MAX) + struct ovsrec_bridge; struct controller_ctx;