773311
From d46b2e1f3b31509849441cde28475a8d48a6624f Mon Sep 17 00:00:00 2001
773311
From: Dumitru Ceara <dceara@redhat.com>
773311
Date: Fri, 17 Apr 2020 23:54:25 +0200
773311
Subject: [PATCH] ovn-northd: Limit IPv6 ND NS/RA/RS to the local network.
773311
773311
Neighbor solicitation packets for router owned IPs are replied to in
773311
table IN_IP_INPUT at a higher priority than flows relay IPv6 multicast
773311
traffic when needed. All other NS/NA packets received at this point can
773311
be safely dropped.
773311
773311
However, router advertisement and router solicitation packets are
773311
processed at a later stage, in ND_RA_OPTIONS/ND_RA_RESPONSE. These
773311
packets need to be allowed in table IN_IP_INPUT.
773311
773311
Commit 677a3ba4d66b incorrectly allowed all IPv6 multicast traffic
773311
destined to all-nodes in table IN_IP_INPUT. Instead, only ND_RA and
773311
ND_RS packets should be allowed. All others were either already
773311
processed or should be dropped. If multicast relay is enabled then IPv6
773311
multicast traffic that's not destined to reserved groups should also be
773311
allowed.
773311
773311
Furthermore, router solicitation and advertisement packets that don't
773311
get processed in tables ND_RA_OPTIONS/ND_RA_RESPONSE should be dropped
773311
in IN_IP_ROUTING because they should never be routed.
773311
773311
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1825334
773311
Reported-by: Jakub Libosvar <jlibosva@redhat.com>
773311
Fixes: 677a3ba4d66b ("ovn: Add MLD support.")
773311
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
773311
Signed-off-by: Numan Siddique <numans@ovn.org>
773311
773311
(cherry-picked from upstream branch-20.03 commit 0924bcb07ef25f93fde683fe8f15d376eca005ec)
773311
773311
Change-Id: I1d060e5d40f344b890974e6ad0c0960ea280f050
773311
---
773311
 northd/ovn-northd.8.xml | 49 +++++++++++++++++++++++++++--------------
773311
 northd/ovn-northd.c     | 43 +++++++++++++++++++++++++-----------
773311
 2 files changed, 62 insertions(+), 30 deletions(-)
773311
773311
diff --git a/northd/ovn-northd.8.xml b/northd/ovn-northd.8.xml
773311
index 82c86f636..efcc4b7fc 100644
773311
--- a/northd/ovn-northd.8.xml
773311
+++ b/northd/ovn-northd.8.xml
773311
@@ -1668,22 +1668,6 @@ next;
773311
           router.
773311
       
773311
 
773311
-      
  • 773311
    -        

    773311
    -          A priority-87 flow explicitly allows IPv6 multicast traffic that is
    773311
    -          supposed to reach the router pipeline (e.g., neighbor solicitations
    773311
    -          and traffic destined to the All-Routers multicast group).
    773311
    -        

    773311
    -      
    773311
    -
    773311
    -      
  • 773311
    -        

    773311
    -          A priority-86 flow allows IP multicast traffic if
    773311
    -          <ref column="options" table="Logical_Router"/>:mcast_relay='true',
    773311
    -          otherwise drops it.
    773311
    -        

    773311
    -      
    773311
    -
    773311
           
  • 773311
             

    773311
               ICMP echo reply.  These flows reply to ICMP echo requests received
    773311
    @@ -1944,6 +1928,29 @@ nd.tll = external_mac;
    773311
             packets.
    773311
           
    773311
     
    773311
    +      
  • 773311
    +        

    773311
    +          A priority-84 flow explicitly allows IPv6 multicast traffic that is
    773311
    +          supposed to reach the router pipeline (i.e., router solicitation
    773311
    +          and router advertisement packets).
    773311
    +        

    773311
    +      
    773311
    +
    773311
    +      
  • 773311
    +        

    773311
    +          A priority-83 flow explicitly drops IPv6 multicast traffic that is
    773311
    +          destined to reserved multicast groups.
    773311
    +        

    773311
    +      
    773311
    +
    773311
    +      
  • 773311
    +        

    773311
    +          A priority-82 flow allows IP multicast traffic if
    773311
    +          <ref column="options" table="Logical_Router"/>:mcast_relay='true',
    773311
    +          otherwise drops it.
    773311
    +        

    773311
    +      
    773311
    +
    773311
           
  • 773311
             

    773311
               UDP port unreachable.  Priority-80 flows generate ICMP port
    773311
    @@ -2440,6 +2447,13 @@ output;
    773311
         

    773311
     
    773311
         
      773311
      +      
    • 773311
      +        

      773311
      +          Priority-550 flow that drops IPv6 Router Solicitation/Advertisement
      773311
      +          packets that were not processed in previous tables.
      773311
      +        

      773311
      +      
      773311
      +
      773311
             
    • 773311
               

      773311
                 Priority-500 flows that match IP multicast traffic destined to
      773311
      @@ -2457,7 +2471,8 @@ output;
      773311
                 multicast group, which ovn-northd populates with the
      773311
                 logical ports that have
      773311
                 <ref column="options" table="Logical_Router_Port"/>
      773311
      -          :mcast_flood='true'.
      773311
      +          :mcast_flood='true'. If no router ports are configured
      773311
      +          to flood multicast traffic the packets are dropped.
      773311
               

      773311
             
      773311
       
      773311
      diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
      773311
      index 1f1238d23..f7d3988d7 100644
      773311
      --- a/northd/ovn-northd.c
      773311
      +++ b/northd/ovn-northd.c
      773311
      @@ -8002,17 +8002,6 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
      773311
       
      773311
               /* Priority-90 flows reply to ARP requests and ND packets. */
      773311
       
      773311
      -        /* Allow IPv6 multicast traffic that's supposed to reach the
      773311
      -         * router pipeline (e.g., neighbor solicitations).
      773311
      -         */
      773311
      -        ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_INPUT, 87, "ip6.mcast_flood",
      773311
      -                      "next;");
      773311
      -
      773311
      -        /* Allow multicast if relay enabled (priority 86). */
      773311
      -        ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_INPUT, 86,
      773311
      -                      "ip4.mcast || ip6.mcast",
      773311
      -                      od->mcast_info.rtr.relay ? "next;" : "drop;");
      773311
      -
      773311
               /* Drop ARP packets (priority 85). ARP request packets for router's own
      773311
                * IPs are handled with priority-90 flows.
      773311
                * Drop IPv6 ND packets (priority 85). ND NA packets for router's own
      773311
      @@ -8021,6 +8010,21 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
      773311
               ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_INPUT, 85,
      773311
                             "arp || nd", "drop;");
      773311
       
      773311
      +        /* Allow IPv6 multicast traffic that's supposed to reach the
      773311
      +         * router pipeline (e.g., router solicitations).
      773311
      +         */
      773311
      +        ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_INPUT, 84, "nd_rs || nd_ra",
      773311
      +                      "next;");
      773311
      +
      773311
      +        /* Drop other reserved multicast. */
      773311
      +        ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_INPUT, 83,
      773311
      +                      "ip6.mcast_rsvd", "drop;");
      773311
      +
      773311
      +        /* Allow other multicast if relay enabled (priority 82). */
      773311
      +        ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_INPUT, 82,
      773311
      +                      "ip4.mcast || ip6.mcast",
      773311
      +                      od->mcast_info.rtr.relay ? "next;" : "drop;");
      773311
      +
      773311
               /* Drop Ethernet local broadcast.  By definition this traffic should
      773311
                * not be forwarded.*/
      773311
               ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_INPUT, 50,
      773311
      @@ -9520,7 +9524,17 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
      773311
            * advance to next table (priority 500).
      773311
            */
      773311
           HMAP_FOR_EACH (od, key_node, datapaths) {
      773311
      -        if (!od->nbr || !od->mcast_info.rtr.relay) {
      773311
      +        if (!od->nbr) {
      773311
      +            continue;
      773311
      +        }
      773311
      +
      773311
      +        /* Drop IPv6 multicast traffic that shouldn't be forwarded,
      773311
      +         * i.e., router solicitation and router advertisement.
      773311
      +         */
      773311
      +        ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_ROUTING, 550,
      773311
      +                      "nd_rs || nd_ra", "drop;");
      773311
      +
      773311
      +        if (!od->mcast_info.rtr.relay) {
      773311
                   continue;
      773311
               }
      773311
       
      773311
      @@ -9551,7 +9565,7 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
      773311
               }
      773311
       
      773311
               /* If needed, flood unregistered multicast on statically configured
      773311
      -         * ports.
      773311
      +         * ports. Otherwise drop any multicast traffic.
      773311
                */
      773311
               if (od->mcast_info.rtr.flood_static) {
      773311
                   ds_clear(&actions);
      773311
      @@ -9562,6 +9576,9 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
      773311
                                       "ip.ttl--; "
      773311
                                       "next; "
      773311
                                 "};");
      773311
      +        } else {
      773311
      +            ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_ROUTING, 450,
      773311
      +                          "ip4.mcast || ip6.mcast", "drop;");
      773311
               }
      773311
           }
      773311
       
      773311
      -- 
      773311
      2.25.1
      773311