Enable VLAN for ipmitool

```
Currently creating VLAN using ipmitool was failing with error
"LAN parameter failed"
Analyzed and identified 3 issues
1) using command "ipmitool lan set 1 vlan id 2" not able to create
the vlan interface
2) After creating VLAN from ipmitool, ip address getting lost for
ethernet interface eth0 and not able to reach BMC.
3) while checking interface name is part of the network path
"/xyz/openbmc_project/network" it is observed the it is returning
false if the path contains VLAN interface
"/xyz/openbmc_project/network/eth0_2".

Code was only checking for the '/' after
"/xyz/openbmc_project/network/eth0" since this was older
implementation where VLAN is part of ethernet interface eth0.

Solution : It is found that before creating the vlan the
 "deconfigureChannel" API does thwo things
1) delete dbus Object If Exists 2) Reset the DHCP ip address for
parent ethernet interface e.g. eth0

For issue 1) it is found there are read only dbus path getting
created e.g. /xyz/openbmc_project/network/eth0/_310_2e0_2e2_2e15_2f24
while each ethernet interface is created here basically
_310_2e0_2e2_2e15_2f24 translates to the IP address
10.0.2.15 with a subnet mask of 24.
these paths can't be deleted and while deleting these paths
exception thrown.
To fix this, I have added to check if the exception of type
"xyz.openbmc_project.Common.Error.NotAllowed"
then not to throw further exception
For issue 2) I am keeping local copy of the params before creating
VLAN and applying the settings again after creating the VLAN
so that all the configurations of eth0 are restored.

for issue 3)  Added code to handle the VLAN path
"/xyz/openbmc_project/network/eth0_2" by adding check for '' after
path /xyz/openbmc_project/network/eth0 to inform that VLAN interface
starts after

Testing :

root@:~# ipmitool lan set 1 vlan id 2

root@:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 86:82:68:B8:2F:5C
          inet addr:IP  Bcast:IP  Mask:255.255.255.0
          inet6 addr: fe80::8482:68ff:feb8:2f5c/64 Scope:Link
          inet6 addr: fec0::8482:68ff:feb8:2f5c/64 Scope:Site
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:763 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1329 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:94059 (91.8 KiB)  TX bytes:1366477 (1.3 MiB)
          Interrupt:38

eth0.2    Link encap:Ethernet  HWaddr 86:82:68:B8:2F:5C
          inet addr:169.254.86.79  Bcast:10.0.2.255 Mask:255.255.255.0
          inet6 addr: fe80::8482:68ff:feb8:2f5c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:37 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:5178 (5.0 KiB)

#list vlan in ethernet interface
url -k -u root:0penBmc  -X GET https://BMCIP/redfish/v1/Managers/bmc/EthernetInterfaces
{
  "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces",
  "@odata.type": "#EthernetInterfaceCollection.EthernetInter
faceCollection",
  "Description": "Collection of EthernetInterfaces for this Manager",
  "Members": [
    {
      "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0"
    },
    {
     "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0_2"
    }
  ],
  "Members@odata.count": 2,
  "Name": "Ethernet Network Interface Collection"
}

root@:~# ipmitool lan set 1 vlan id 2
IANA PEN registry open failed: No such file or directory
Failed to load entries from IANA PEN Registry

root@:~#
root@:~# ifconfig
eth0      Link encap:Ethernet  HWaddr DE:7F:3D:A4:94:CD
          inet addr:IP  Bcast:IP  Mask:255.255.255.0
          inet6 addr: fe80::dc7f:3dff:fea4:94cd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:33 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3086 (3.0 KiB)  TX bytes:3863 (3.7 KiB)
          Interrupt:38

eth0.2    Link encap:Ethernet  HWaddr DE:7F:3D:A4:94:CD
          inet6 addr: fe80::dc7f:3dff:fea4:94cd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:90 (90.0 B)

root@:~# ipmitool lan set 1 vlan id off
IANA PEN registry open failed: No such file or directory
Failed to load entries from IANA PEN Registry
root@:~#
root@:~# ifconfig
eth0      Link encap:Ethernet  HWaddr DE:7F:3D:A4:94:CD
          inet6 addr: fec0::dc7f:3dff:fea4:94cd/64 Scope:Site
          inet6 addr: fe80::dc7f:3dff:fea4:94cd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14 errors:0 dropped:0 overruns:0 frame:0
          TX packets:69 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3268 (3.1 KiB)  TX bytes:7576 (7.3 KiB)
          Interrupt:38
```

Change-Id: I5cf6c52451040ccbdf391daca070da72fc356bef
Signed-off-by: Chandramohan Harkude <chandramohan.harkude@gmail.com>
diff --git a/transporthandler.cpp b/transporthandler.cpp
index 9b59a8c..6735ee6 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -68,7 +68,9 @@
     constexpr auto rs = PATH_ROOT.size() + 1; // ROOT + separator
     const auto is = rs + ifname.size();       // ROOT + sep + ifname
     return path.size() > rs && path.substr(rs).starts_with(ifname) &&
-           (path.size() == is || path[is] == '/');
+           (path.size() == is || path[is] == '/' ||
+            path[is] == '_'); // handle VLAN IF uses '_' e.g.
+                              // /xyz/openbmc_project/network/eth0_2
 }
 
 std::optional<ChannelParams> maybeGetChannelParams(sdbusplus::bus_t& bus,
@@ -209,9 +211,12 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
+        // handle Delete Interface DBus errors
         if (strcmp(e.name(),
                    "xyz.openbmc_project.Common.Error.InternalFailure") != 0 &&
-            strcmp(e.name(), "org.freedesktop.DBus.Error.UnknownObject") != 0)
+            strcmp(e.name(), "org.freedesktop.DBus.Error.UnknownObject") != 0 &&
+            strcmp(e.name(), "xyz.openbmc_project.Common.Error.NotAllowed") !=
+                0)
         {
             // We want to rethrow real errors
             throw;
@@ -567,11 +572,17 @@
     ObjectLookupCache neighbors(bus, params, INTF_NEIGHBOR);
     auto neighbor4 = findGatewayNeighbor<AF_INET>(bus, params, neighbors);
     auto neighbor6 = findGatewayNeighbor<AF_INET6>(bus, params, neighbors);
+    // Make copy of params to retain the previous configs
+    ChannelParams parentIntParams = params;
 
     deconfigureChannel(bus, params);
     createVLAN(bus, params, vlan);
 
     // Re-establish the saved settings
+    setEthProp(bus, parentIntParams, "DHCP4", dhcp4);
+    setEthProp(bus, parentIntParams, "DHCP6", dhcp6);
+    setEthProp(bus, parentIntParams, "IPv6AcceptRA", ra);
+
     setEthProp(bus, params, "DHCP4", dhcp4);
     setEthProp(bus, params, "DHCP6", dhcp6);
     setEthProp(bus, params, "IPv6AcceptRA", ra);