Add "timeout" column in MAC_Binding to support cache aging. The ARP/NA cache expiring will be removed and logical router send ARP/NS to get IP-MAC binding.
Signed-off-by: nickcooper-zhangtonghao <nickcooper-zhangtong...@opencloud.tech> --- ovn/controller/pinctrl.c | 25 ++++++++++++++++++------- ovn/ovn-sb.ovsschema | 3 ++- ovn/ovn-sb.xml | 5 +++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c index 9728e12..fb8141b 100644 --- a/ovn/controller/pinctrl.c +++ b/ovn/controller/pinctrl.c @@ -1011,7 +1011,7 @@ pinctrl_handle_put_mac_binding(const struct flow *md, inet_ntop(AF_INET6, &ip6, ip_s, sizeof(ip_s)); } - /* Check to see whether the corresponding ARP request exists in the cache. + /* Check to see whether the corresponding ARP/NS request exists in the cache. * If we don't find it, return directly. */ bool update = pinctrl_find_delete_arp_request_cache(dp_key, port_key, ip_s); if (!update) { @@ -1042,9 +1042,6 @@ run_put_mac_binding(struct controller_ctx *ctx, const struct lport_index *lports, const struct put_mac_binding *pmb) { - if (time_msec() > pmb->timestamp + 1000) { - return; - } /* Convert logical datapath and logical port key into lport. */ const struct sbrec_port_binding *pb @@ -1066,8 +1063,8 @@ run_put_mac_binding(struct controller_ctx *ctx, * port. * * XXX This is not very efficient. */ - const struct sbrec_mac_binding *b; - SBREC_MAC_BINDING_FOR_EACH (b, ctx->ovnsb_idl) { + const struct sbrec_mac_binding *b, *next; + SBREC_MAC_BINDING_FOR_EACH_SAFE (b, next, ctx->ovnsb_idl) { if (!strcmp(b->logical_port, pb->logical_port) && !strcmp(b->ip, pmb->ip_s)) { if (strcmp(b->mac, mac_string)) { @@ -1082,6 +1079,10 @@ run_put_mac_binding(struct controller_ctx *ctx, sbrec_mac_binding_set_logical_port(b, pb->logical_port); sbrec_mac_binding_set_ip(b, pmb->ip_s); sbrec_mac_binding_set_mac(b, mac_string); + + struct ds timeout = DS_EMPTY_INITIALIZER; + ds_put_format(&timeout, "%lld", time_msec()); + sbrec_mac_binding_set_timeout(b, ds_cstr(&timeout)); sbrec_mac_binding_set_datapath(b, pb->datapath); } @@ -1093,9 +1094,19 @@ run_put_mac_bindings(struct controller_ctx *ctx, return; } - /* The ARP request expiring will be remove.*/ + /* The ARP request expiring will be removed.*/ run_update_arp_request_cache(); + /* The IP-MAC binding expiring for this logical + * port will be removed from the database. Expire time is + * 15min*/ + const struct sbrec_mac_binding *b, *next; + SBREC_MAC_BINDING_FOR_EACH_SAFE (b, next, ctx->ovnsb_idl) { + if (time_msec() > strtoll(b->timeout, NULL, 10) + 15*60000) { + sbrec_mac_binding_delete(b); + } + } + const struct put_mac_binding *pmb; HMAP_FOR_EACH (pmb, hmap_node, &put_mac_bindings) { run_put_mac_binding(ctx, lports, pmb); diff --git a/ovn/ovn-sb.ovsschema b/ovn/ovn-sb.ovsschema index 8604b4e..e9a68eb 100644 --- a/ovn/ovn-sb.ovsschema +++ b/ovn/ovn-sb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_Southbound", "version": "1.8.0", - "cksum": "59582657 7376", + "cksum": "413692163 7423", "tables": { "SB_Global": { "columns": { @@ -126,6 +126,7 @@ "logical_port": {"type": "string"}, "ip": {"type": "string"}, "mac": {"type": "string"}, + "timeout": {"type": "string"}, "datapath": {"type": {"key": {"type": "uuid", "refTable": "Datapath_Binding"}}}}, "indexes": [["logical_port", "ip"]], diff --git a/ovn/ovn-sb.xml b/ovn/ovn-sb.xml index 0829cbc..233ea30 100644 --- a/ovn/ovn-sb.xml +++ b/ovn/ovn-sb.xml @@ -1960,6 +1960,11 @@ tcp.flags = RST; <column name="mac"> The Ethernet address to which the IP is bound. </column> + + <column name="timeout"> + The ARP/ND cache timeout. + </column> + <column name="datapath"> The logical datapath to which the logical port belongs. </column> -- 1.8.3.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev