When the iptoip.xml contains multiple <conf> blocks that contain multiple <port> blocks only the first one is properly applied to the ipvs table.
for instance if the xml file contains
<conf>
<origin>208.31.36.89</origin>
<protocol>t</protocol>
<scheduler>rr</scheduler>
<destination>192.168.0.64</destination>
<port>80</port>
<port>81</port>
<port>110</port>
<port>995</port>
</conf>
<conf>
<origin>208.31.36.89</origin>
<protocol>t</protocol>
<scheduler>rr</scheduler>
<destination>192.168.0.154</destination>
<port>13202</port>
<port>35018</port>
</conf>
<conf>
<origin>208.31.36.89</origin>
<protocol>u</protocol>
<scheduler>rr</scheduler>
<destination>192.168.0.154</destination>
<port>13202</port>
<port>35018</port>
</conf>
<conf>
<origin>208.31.36.89</origin>
<protocol>t</protocol>
<scheduler>rr</scheduler>
<destination>192.168.0.254</destination>
<port>631</port>
</conf>
I will get an ipvs table like
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 208.31.36.89:81 rr
-> 192.168.0.64:81 Masq 1 0 0
TCP 208.31.36.89:80 rr
-> 192.168.0.64:80 Masq 1 0 0
TCP 208.31.36.89:631 rr
-> 192.168.0.254:631 Masq 1 0 0
TCP 208.31.36.89:110 rr
-> 192.168.0.64:110 Masq 1 0 0
TCP 208.31.36.89:995 rr
-> 192.168.0.64:995 Masq 1 0 0
All the entries for 192.168.0.154 are missing
However if line 36
my $p = 0;
is moved into the xml_update subroutine.
We get an ipvs table that looks like it should.
The above table plus
TCP 208.31.36.89:13202 rr
-> 192.168.0.154:13202 Masq 1 0 0
TCP 208.31.36.89:35018 rr
-> 192.168.0.154:35018 Masq 1 3 4
UDP 208.31.36.89:13202 rr
-> 192.168.0.154:13202 Masq 1 0 431
UDP 208.31.36.89:35018 rr
-> 192.168.0.154:35018 Masq 1 0 918
Diff file of the changes described above.