diff mbox series

[ovs-dev,v2] northd-ddlog: Add proxy arp flows for configured addresses in lsp router port.

Message ID 20210701124521.2095748-1-numans@ovn.org
State Accepted
Headers show
Series [ovs-dev,v2] northd-ddlog: Add proxy arp flows for configured addresses in lsp router port. | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning
ovsrobot/github-robot success github build: passed

Commit Message

Numan Siddique July 1, 2021, 12:45 p.m. UTC
From: Numan Siddique <numans@ovn.org>

The commit [1] didn't add the ddlog part.

[1] - 8087cbc7462("ovn-northd.c: Add proxy ARP support to OVN")

Signed-off-by: Numan Siddique <numans@ovn.org>
---
 northd/ovn.dl        |  1 +
 northd/ovn.rs        | 13 +++++++++++++
 northd/ovn_northd.dl | 38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+)

Comments

0-day Robot July 1, 2021, 1:01 p.m. UTC | #1
Bleep bloop.  Greetings Numan Siddique, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
WARNING: Line is 85 characters long (recommended limit is 79)
#37 FILE: northd/ovn.rs:187:
pub fn extract_ip_addresses(address: &String) -> ddlog_std::Option<lport_addresses> {

WARNING: Line is 105 characters long (recommended limit is 79)
#56 FILE: northd/ovn.rs:638:
        pub fn extract_ip_addresses(address: *const raw::c_char, laddrs: *mut lport_addresses_c) -> bool;

Lines checked: 111, Warnings: 2, Errors: 0


Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
Ben Pfaff July 1, 2021, 5:44 p.m. UTC | #2
On Thu, Jul 01, 2021 at 08:45:21AM -0400, numans@ovn.org wrote:
> From: Numan Siddique <numans@ovn.org>
> 
> The commit [1] didn't add the ddlog part.
> 
> [1] - 8087cbc7462("ovn-northd.c: Add proxy ARP support to OVN")
> 
> Signed-off-by: Numan Siddique <numans@ovn.org>

This fixes test failures for me.  Thank you!

Acked-by: Ben Pfaff <blp@ovn.org>
Numan Siddique July 1, 2021, 6:27 p.m. UTC | #3
On Thu, Jul 1, 2021 at 1:45 PM Ben Pfaff <blp@ovn.org> wrote:
>
> On Thu, Jul 01, 2021 at 08:45:21AM -0400, numans@ovn.org wrote:
> > From: Numan Siddique <numans@ovn.org>
> >
> > The commit [1] didn't add the ddlog part.
> >
> > [1] - 8087cbc7462("ovn-northd.c: Add proxy ARP support to OVN")
> >
> > Signed-off-by: Numan Siddique <numans@ovn.org>
>
> This fixes test failures for me.  Thank you!
>
> Acked-by: Ben Pfaff <blp@ovn.org>

Thanks.  Applied.

Numan

> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
diff mbox series

Patch

diff --git a/northd/ovn.dl b/northd/ovn.dl
index f23ea3b9e1..3c7a734ddb 100644
--- a/northd/ovn.dl
+++ b/northd/ovn.dl
@@ -364,6 +364,7 @@  extern function is_dynamic_lsp_address(addr: string): bool
 extern function extract_lsp_addresses(address: string): Option<lport_addresses>
 extern function extract_addresses(address: string): Option<lport_addresses>
 extern function extract_lrp_networks(mac: string, networks: Set<string>): Option<lport_addresses>
+extern function extract_ip_addresses(address: string): Option<lport_addresses>
 
 extern function split_addresses(addr: string): (Set<string>, Set<string>)
 
diff --git a/northd/ovn.rs b/northd/ovn.rs
index d44f83bc75..5f0939409c 100644
--- a/northd/ovn.rs
+++ b/northd/ovn.rs
@@ -184,6 +184,18 @@  pub fn extract_lrp_networks(mac: &String, networks: &ddlog_std::Set<String>) ->
     }
 }
 
+pub fn extract_ip_addresses(address: &String) -> ddlog_std::Option<lport_addresses> {
+    unsafe {
+        let mut laddrs: lport_addresses_c = Default::default();
+        if ovn_c::extract_ip_addresses(string2cstr(address).as_ptr(),
+                                       &mut laddrs as *mut lport_addresses_c) {
+            ddlog_std::Option::Some{x: laddrs.into_ddlog()}
+        } else {
+            ddlog_std::Option::None
+        }
+    }
+}
+
 pub fn ovn_internal_version() -> String {
     unsafe {
         let s = ovn_c::ovn_get_internal_version();
@@ -623,6 +635,7 @@  mod ovn_c {
         pub fn extract_addresses(address: *const raw::c_char, laddrs: *mut lport_addresses_c, ofs: *mut raw::c_int) -> bool;
         pub fn extract_lrp_networks__(mac: *const raw::c_char, networks: *const *const raw::c_char,
                                       n_networks: libc::size_t, laddrs: *mut lport_addresses_c) -> bool;
+        pub fn extract_ip_addresses(address: *const raw::c_char, laddrs: *mut lport_addresses_c) -> bool;
         pub fn destroy_lport_addresses(addrs: *mut lport_addresses_c);
         pub fn is_dynamic_lsp_address(address: *const raw::c_char) -> bool;
         pub fn split_addresses(addresses: *const raw::c_char, ip4_addrs: *mut ovs_svec, ipv6_addrs: *mut ovs_svec);
diff --git a/northd/ovn_northd.dl b/northd/ovn_northd.dl
index ce6680e97f..80ec68bbd7 100644
--- a/northd/ovn_northd.dl
+++ b/northd/ovn_northd.dl
@@ -3350,6 +3350,44 @@  for (CheckLspIsUp[check_lsp_is_up]) {
     }
 }
 
+Flow(.logical_datapath = sw._uuid,
+         .stage            = s_SWITCH_IN_ARP_ND_RSP(),
+         .priority         = 50,
+         .__match          = __match,
+         .actions          = __actions,
+         .external_ids     = stage_hint(sp.lsp._uuid)) :-
+
+    sp in &SwitchPort(.sw = sw, .peer = Some{rp}),
+    rp.is_enabled(),
+    var proxy_ips = {
+        match (sp.lsp.options.get("arp_proxy")) {
+            None -> "",
+            Some {addresses} -> {
+                match (extract_ip_addresses(addresses)) {
+                    None -> "",
+                    Some{addr} -> {
+                        var ip4_addrs = vec_empty();
+                        for (ip4 in addr.ipv4_addrs) {
+                            ip4_addrs.push("${ip4.addr}")
+                        };
+                        string_join(ip4_addrs, ",")
+                    }
+                }
+            }
+        }
+    },
+    proxy_ips != "",
+    var __match = "arp.op == 1 && arp.tpa == {" ++ proxy_ips ++ "}",
+    var __actions = "eth.dst = eth.src; "
+                    "eth.src = ${rp.networks.ea}; "
+                    "arp.op = 2; /* ARP reply */ "
+                    "arp.tha = arp.sha; "
+                    "arp.sha = ${rp.networks.ea}; "
+                    "arp.tpa <-> arp.spa; "
+                    "outport = inport; "
+                    "flags.loopback = 1; "
+                    "output;".
+
 /* For ND solicitations, we need to listen for both the
  * unicast IPv6 address and its all-nodes multicast address,
  * but always respond with the unicast IPv6 address. */