Hi there and a happy new year,

I am currently experimenting with OVN VIF plugins and the port creation process seems to have a minor bug.

Bug Description
---

During writing a custom plugin, I read the docs for the `vif_plug_port_prepare` function and determined, I should return `false` in case of the plugin not wanting to create or update a port:

> The VIF plug implementation should return 'true' if it wants the caller to create/update a port/interface, 'false' otherwise.

When returning `false`, however, I noticed that the ovn-controller process just dies with a SEGFAULT, regardless of whether I fill a context or not. I expected the controller to just spit out a message that the plugin does not want to do anything but no crash.

Version Information
---

OVN Version: ovn-controller 25.09.0
OVN Commit Hash: 8890abf5a25b7b67f08aca8917c1d00cf2296a56 (but problem persists with the current HEAD).


Possible Solution
---

In `ovn/controller/vif-plug.c` (see https://github.com/ovn-org/ovn/blob/3708cf59ea3759152adaa875dbf244e2e4898650/controller/vif-plug.c#L330-L339), I found that in case of the plugin returning `false` in the `..._prepare` function, the context is destroyed and `consider_plug_lport__` returns `true`. Thus, `consider_plug_lport` accesses the (already destroyed) context and crashes the controller.

A possible fix would be to return `false` there, too:

```diff
diff --git a/controller/vif-plug.c b/controller/vif-plug.c
index 1fa536cad..06a13c47b 100644
--- a/controller/vif-plug.c
+++ b/controller/vif-plug.c
@@ -336,7 +336,7 @@ consider_plug_lport__(const struct vif_plug_class *vif_plug,
                      "plug provider.",
                      pb->logical_port);
         destroy_port_ctx(vif_plug_port_ctx);
-        return true;
+        return false;
     }
     *vif_plug_port_ctx_ptr = vif_plug_port_ctx;
     return true;
```

If I am doing something wrong, I am happy to be corrected.

Best regards
Felix
_______________________________________________
discuss mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-discuss

Reply via email to