<div dir="ltr">Ok, agreed it should be decoupled from updown.<div><br></div><div>I'm trying to determine where to store the ref counted IP addresses (v4/v6). I could add it to the pluto_xfrmi struct (kernel_xfrm_interface.c/h) but then that would not include VTI interfaces. Everything related to creating VTI interfaces is performed in the updown script. If we want to also refcount IPs for VTI interfaces, then perhaps the best place to store it would be in connections.c/h?</div><div><br></div><div>If we just want to do this for XFRMI interfaces, then I could just add a pointer to the following new struct to pluto_xfrmi (which would be a simple linked list, similar to struct pluto_xfrmi) as follows:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace">struct pluto_ips {</font></div><div><font face="monospace">    ip_address ip;<br></font></div><div><font face="monospace">    </font><span style="font-family:monospace">refcnt_t refcnt;</span></div><div><font face="monospace">    bool pluto_added;</font></div><div><font face="monospace">    struct pluto_ips *next;</font></div><div><font face="monospace">}; </font></div></blockquote><div><br></div><div>There is still the issue of how/where to remove the IP from the interface. Currently this never happens, so should we do this in the updown script or from Pluto? Considering the IP addresses are added to the interfaces in the updown script, it seems logical to also remove them in the updown script.</div><div><br></div><div>Thoughts??</div><div><br></div><div>Regards,</div><div><br></div><div>Brady</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 2, 2023 at 6:15 PM Paul Wouters <<a href="mailto:paul@nohats.ca">paul@nohats.ca</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, 2 Mar 2023, Brady Johnson wrote:<br>
<br>
(CC:ing dev list, because why not)<br>
<br>
> I have started looking into how to ref count the IP addresses. It looks like currently the IP addresses are set on the interfaces in<br>
> the updown shell script with the "up-client" verb. Currently the addresses are never deleted from the interfaces. I verified this<br>
> when manually testing my previous patch.<br>
> To refcount when addresses are added, I could just add code to the do_updown() function in programs/pluto/updown.c. But for<br>
> deleting, I could also control that in the do_updown() function, but I guess I would also need to modify the updown script to<br>
> actually remove the IP from the interface.<br>
> <br>
> This is all on Linux with xfrmi/vti interfaces.<br>
<br>
It should not be too tightly coupled with "updown", because we are<br>
thinking of trying to make leftupdown= optional with a default to no,<br>
and move all the "standard" things into pluto.<br>
<br>
Most of the things we do in "updown" are related to IP addresses,<br>
routing and DNS settings. When we split DNS into its own helper, it<br>
avoids all those calls/checks when there is no need.<br>
<br>
Similarly, when no IP addresses are being removed / added or routes<br>
changed (or MTUs set via route changes), we hope to avoid calling<br>
updown (which is very expensive to call)<br>
<br>
Note also that updown as a "verb", giving it different meanings. It<br>
can be: up/down host, up/down client, up/down route. The route mostly<br>
stems from KLIPS that triggered the IPsec kernel code by routing into<br>
"ipsecX" interfaces. KLIPS was removed and usually those route calls<br>
are no longer needed.<br>
<br>
So while the locations where updown is called by pluto might be good<br>
spots to add your refcounting call, I wouldn't couple it too tightly<br>
to updown itself.<br>
<br>
Paul<br>
</blockquote></div>