From patchwork Mon Jul 10 08:46:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangchuanlei X-Patchwork-Id: 1805603 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QzynK70cyz20WT for ; Mon, 10 Jul 2023 19:07:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 9B0E2409E6; Mon, 10 Jul 2023 09:07:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 9B0E2409E6 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Yp5bY2X9CoW5; Mon, 10 Jul 2023 09:07:14 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 3BBF040382; Mon, 10 Jul 2023 09:07:13 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 3BBF040382 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 02522C0072; Mon, 10 Jul 2023 09:07:13 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id E3BD3C0032 for ; Mon, 10 Jul 2023 09:07:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id AF4B060E77 for ; Mon, 10 Jul 2023 09:07:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org AF4B060E77 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w9Hf3oFThMwx for ; Mon, 10 Jul 2023 09:07:09 +0000 (UTC) X-Greylist: delayed 00:14:21 by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 45A7460E59 Received: from mail-vip.corpemail.net (mail-vip.corpemail.net [162.243.126.186]) by smtp3.osuosl.org (Postfix) with ESMTPS id 45A7460E59 for ; Mon, 10 Jul 2023 09:07:09 +0000 (UTC) Received: from ssh248.corpemail.net by ssh248.corpemail.net ((D)) with ASMTP (SSL) id GHF00118 for ; Mon, 10 Jul 2023 16:46:18 +0800 Received: from localhost.localdomain (10.180.207.207) by jtjnmail201608.home.langchao.com (10.100.2.8) with Microsoft SMTP Server id 15.1.2507.27; Mon, 10 Jul 2023 16:46:19 +0800 From: wangchuanlei To: Date: Mon, 10 Jul 2023 04:46:14 -0400 Message-ID: <20230710084614.37833-1-wangchuanlei@inspur.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Originating-IP: [10.180.207.207] tUid: 202371016461803064ff1812a2b6da6adaf2f33e50fcd X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com Subject: [ovs-dev] [PATCH ovn] northd: Lookup route policy before ip routing X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" If there is no route in table ip_routing, the route policy item in table policy is useless. Because route policy has a higher priority than ip routing, so moddify the table id of IP_ROUTING and POLICY is a little better.By this way, there is no need reroute any more, this should be more effienct. Signed-off-by: wangchuanlei --- northd/northd.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index a45c8b53a..35187abf8 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -174,10 +174,10 @@ enum ovn_stage { PIPELINE_STAGE(ROUTER, IN, ND_RA_OPTIONS, 10, "lr_in_nd_ra_options") \ PIPELINE_STAGE(ROUTER, IN, ND_RA_RESPONSE, 11, "lr_in_nd_ra_response") \ PIPELINE_STAGE(ROUTER, IN, IP_ROUTING_PRE, 12, "lr_in_ip_routing_pre") \ - PIPELINE_STAGE(ROUTER, IN, IP_ROUTING, 13, "lr_in_ip_routing") \ - PIPELINE_STAGE(ROUTER, IN, IP_ROUTING_ECMP, 14, "lr_in_ip_routing_ecmp") \ - PIPELINE_STAGE(ROUTER, IN, POLICY, 15, "lr_in_policy") \ - PIPELINE_STAGE(ROUTER, IN, POLICY_ECMP, 16, "lr_in_policy_ecmp") \ + PIPELINE_STAGE(ROUTER, IN, POLICY, 13, "lr_in_policy") \ + PIPELINE_STAGE(ROUTER, IN, POLICY_ECMP, 14, "lr_in_policy_ecmp") \ + PIPELINE_STAGE(ROUTER, IN, IP_ROUTING, 15, "lr_in_ip_routing") \ + PIPELINE_STAGE(ROUTER, IN, IP_ROUTING_ECMP, 16, "lr_in_ip_routing_ecmp") \ PIPELINE_STAGE(ROUTER, IN, ARP_RESOLVE, 17, "lr_in_arp_resolve") \ PIPELINE_STAGE(ROUTER, IN, CHK_PKT_LEN, 18, "lr_in_chk_pkt_len") \ PIPELINE_STAGE(ROUTER, IN, LARGER_PKTS, 19, "lr_in_larger_pkts") \ @@ -278,6 +278,7 @@ enum ovn_stage { #define REG_SRC_IPV4 "reg1" #define REG_SRC_IPV6 "xxreg1" #define REG_ROUTE_TABLE_ID "reg7" +#define REG_ROUTE_POLICY "reg2" /* Register used to store backend ipv6 address * for load balancer affinity. */ @@ -10240,6 +10241,7 @@ build_routing_policy_flow(struct hmap *lflows, struct ovn_datapath *od, bool is_ipv4 = strchr(nexthop, '.') ? true : false; ds_put_format(&actions, "%s = %s; " "%s = %s; " + "%s = 1; " "eth.src = %s; " "outport = %s; " "flags.loopback = 1; " @@ -10249,6 +10251,7 @@ build_routing_policy_flow(struct hmap *lflows, struct ovn_datapath *od, nexthop, is_ipv4 ? REG_SRC_IPV4 : REG_SRC_IPV6, lrp_addr_s, + REG_ROUTE_POLICY, out_port->lrp_networks.ea_s, out_port->json_key); @@ -10340,6 +10343,7 @@ build_ecmp_routing_policy_flows(struct hmap *lflows, struct ovn_datapath *od, out_port->json_key); ds_clear(&match); + ds_put_cstr(&actions, REG_ROUTE_POLICY" = 1; "); ds_put_format(&match, REG_ECMP_GROUP_ID" == %"PRIu16" && " REG_ECMP_MEMBER_ID" == %"PRIuSIZE, ecmp_group_id, i + 1); @@ -12911,6 +12915,8 @@ build_mcast_lookup_flows_for_lrouter( */ ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_ROUTING, 10550, "nd_rs || nd_ra", debug_drop_action()); + ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_ROUTING, 10000, + REG_ROUTE_POLICY" == 1", "reg8[0..15] = 0; next;"); if (!od->mcast_info.rtr.relay) { return; }