]> git.puffer.fish Git - matthieu/frr.git/commitdiff
nhrp: Preserve mtu during interface up/down and tunnel source change
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 11 Mar 2021 15:01:10 +0000 (16:01 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 30 Apr 2021 08:33:18 +0000 (10:33 +0200)
preserve mtu upon interface flapping and tunnel source change.

Signed-off-by:Reuben Dowle <reuben.dowle@4rf.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
nhrpd/nhrp_route.c
zebra/if_netlink.c
zebra/zapi_msg.c
zebra/zebra_dplane.c
zebra/zebra_dplane.h

index 1f513b7c0ec17bd74e264c04a5375f425c306477..ee8db277d9a9a69b24966831af3b53ebf6da5605 100644 (file)
@@ -435,6 +435,7 @@ void nhrp_send_zebra_gre_source_set(struct interface *ifp,
        stream_putl(s, ifp->ifindex);
        stream_putl(s, link_idx);
        stream_putl(s, link_vrf_id);
+       stream_putl(s, 0); /* mtu provisioning */
        stream_putw_at(s, 0, stream_get_endp(s));
        zclient_send_message(zclient);
 }
index 44ee8d94692ec9922029d814a45154489a861967..1886f7a54214fc1303916cfe71a0d6a134fb2d40 100644 (file)
@@ -473,6 +473,7 @@ netlink_gre_set_msg_encoder(struct zebra_dplane_ctx *ctx, void *buf,
                char buf[];
        } *req = buf;
        uint32_t link_idx;
+       unsigned int mtu;
        struct rtattr *rta_info, *rta_data;
 
        if (buflen < sizeof(*req))
@@ -486,6 +487,10 @@ netlink_gre_set_msg_encoder(struct zebra_dplane_ctx *ctx, void *buf,
        req->ifi.ifi_index = dplane_ctx_get_ifindex(ctx);
        req->ifi.ifi_change = 0xFFFFFFFF;
        link_idx = dplane_ctx_gre_get_link_ifindex(ctx);
+       mtu = dplane_ctx_gre_get_mtu(ctx);
+
+       if (mtu && !nl_attr_put32(&req->n, buflen, IFLA_MTU, mtu))
+               return 0;
 
        rta_info = nl_attr_nest(&req->n, buflen, IFLA_LINKINFO);
        if (!rta_info)
index 22a6bf496b1d6fb271d3af1ce1ebce7131a6d4c0..75e2f59b98626a13c5c218bae3065a1719777166 100644 (file)
@@ -3438,12 +3438,14 @@ static inline void zebra_gre_source_set(ZAPI_HANDLER_ARGS)
        vrf_id_t vrf_id = zvrf->vrf->vrf_id;
        struct zebra_if *zif, *gre_zif;
        struct zebra_l2info_gre *gre_info;
+       unsigned int mtu;
 
        s = msg;
        STREAM_GETL(s, idx);
        ifp  = if_lookup_by_index(idx, vrf_id);
        STREAM_GETL(s, link_idx);
        STREAM_GETL(s, link_vrf_id);
+       STREAM_GETL(s, mtu);
 
        ifp_link  = if_lookup_by_index(link_idx, link_vrf_id);
        if (!ifp_link || !ifp) {
@@ -3464,11 +3466,14 @@ static inline void zebra_gre_source_set(ZAPI_HANDLER_ARGS)
        if (!gre_info)
                return;
 
-       /* if gre link already set */
-       if (gre_zif->link && gre_zif->link == ifp_link)
+       if (!mtu)
+               mtu = ifp->mtu;
+
+       /* if gre link already set or mtu did not change, do not set it */
+       if (gre_zif->link && gre_zif->link == ifp_link && mtu == ifp->mtu)
                return;
 
-       dplane_gre_set(ifp, ifp_link);
+       dplane_gre_set(ifp, ifp_link, mtu);
 
  stream_failure:
        return;
index 565ab821dfa46e20d017e1c22f31a78d837207c8..b54973a9417f33884d746a8d16059fca21888a9d 100644 (file)
@@ -273,6 +273,7 @@ struct dplane_rule_info {
 
 struct dplane_gre_ctx {
        uint32_t link_ifindex;
+       unsigned int mtu;
 };
 /*
  * The context block used to exchange info about route updates across
@@ -1795,6 +1796,14 @@ dplane_ctx_gre_get_link_ifindex(const struct zebra_dplane_ctx *ctx)
        return ctx->u.gre.link_ifindex;
 }
 
+unsigned int
+dplane_ctx_gre_get_mtu(const struct zebra_dplane_ctx *ctx)
+{
+       DPLANE_CTX_VALID(ctx);
+
+       return ctx->u.gre.mtu;
+}
+
 /* Accessors for PBR rule information */
 int dplane_ctx_rule_get_sock(const struct zebra_dplane_ctx *ctx)
 {
@@ -4152,7 +4161,7 @@ dplane_pbr_ipset_entry_delete(struct zebra_pbr_ipset_entry *ipset)
  * Common helper api for GRE set
  */
 enum zebra_dplane_result
-dplane_gre_set(struct interface *ifp, struct interface *ifp_link)
+dplane_gre_set(struct interface *ifp, struct interface *ifp_link, unsigned int mtu)
 {
        enum zebra_dplane_result result = ZEBRA_DPLANE_REQUEST_FAILURE;
        struct zebra_dplane_ctx *ctx;
@@ -4187,6 +4196,8 @@ dplane_gre_set(struct interface *ifp, struct interface *ifp_link)
        else
                ctx->u.gre.link_ifindex = 0;
 
+       ctx->u.gre.mtu = mtu;
+
        ctx->zd_status = ZEBRA_DPLANE_REQUEST_SUCCESS;
 
        /* Enqueue context for processing */
index 5df58e6e993716bb47b66a4dbb6a3accfd5f351a..5405a7cb85760054ed8d2d9aa914e2308bc5dd1e 100644 (file)
@@ -531,6 +531,8 @@ dplane_ctx_neightable_get_ucast_probes(const struct zebra_dplane_ctx *ctx);
 /* Accessor for GRE set */
 uint32_t
 dplane_ctx_gre_get_link_ifindex(const struct zebra_dplane_ctx *ctx);
+unsigned int
+dplane_ctx_gre_get_mtu(const struct zebra_dplane_ctx *ctx);
 
 /* Namespace info - esp. for netlink communication */
 const struct zebra_dplane_info *dplane_ctx_get_ns(
@@ -704,7 +706,8 @@ enum zebra_dplane_result dplane_neigh_table_update(const struct interface *ifp,
  * Enqueue a GRE set
  */
 enum zebra_dplane_result
-dplane_gre_set(struct interface *ifp, struct interface *ifp_link);
+dplane_gre_set(struct interface *ifp, struct interface *ifp_link,
+              unsigned int mtu);
 
 /* Forward ref of zebra_pbr_rule */
 struct zebra_pbr_rule;