B#12377: Device.IP.Interface. object is not listing WAN interface in few cases

This commit is contained in:
Amin Ben Romdhane 2023-10-23 19:08:56 +02:00
parent 38214d9dee
commit 42234a2e97
5 changed files with 715 additions and 44 deletions

View file

@ -1728,6 +1728,586 @@ Device.DHCPv4.Client.1.Interface => Device.IP.Interface.1
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
```
### 12. PPPoE WAN connection
- **TR-181 Commands**
```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*
obuspa -c add Device.Ethernet.Link.
obuspa -c set Device.Ethernet.Link.1.LowerLayers Device.Ethernet.Interface.3
obuspa -c add Device.PPP.Interface.
obuspa -c set Device.PPP.Interface.1.LowerLayers Device.Ethernet.Link.1
obuspa -c set Device.PPP.Interface.1.Username test
obuspa -c set Device.PPP.Interface.1.Password test
obuspa -c set Device.PPP.Interface.1.Enable 1
obuspa -c add Device.IP.Interface.
obuspa -c set Device.IP.Interface.1.LowerLayers Device.PPP.Interface.1
obuspa -c set Device.IP.Interface.1.Enable 1
```
- **Network UCI Config**
```bash
$ cat /etc/config/network
config interface 'loopback'
option device 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd64:742f:d82c::/48'
config interface 'iface1'
option device 'eth4'
option proto 'pppoe'
option username 'test'
option password 'test'
option disabled '0'
option macaddr '44:D4:37:71:B5:53'
```
- **TR-181 Data Model**
```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.PPP.Interface.1
$ obuspa -c get Device.PPP.Interface.*.LowerLayers
Device.PPP.Interface.1.LowerLayers => Device.Ethernet.Link.1
$ obuspa -c get Device.Ethernet.VLANTermination.*.LowerLayers
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.DHCPv4.Client.*.Interface
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
```
### 13. Switch WAN connection from DHCP to PPP
- **TR-181 Commands**
```bash
obuspa -c set Device.DHCPv4.Client.1.Interface ""
obuspa -c set Device.DHCPv6.Client.1.Interface ""
obuspa -c set Device.IP.Interface.2.LowerLayers ""
obuspa -c add Device.PPP.Interface.
obuspa -c set Device.PPP.Interface.1.LowerLayers Device.Ethernet.Link.2
obuspa -c set Device.PPP.Interface.1.Username test
obuspa -c set Device.PPP.Interface.1.Password test
obuspa -c set Device.PPP.Interface.1.Enable 1
obuspa -c set Device.IP.Interface.2.LowerLayers Device.PPP.Interface.1
```
- **Network UCI Config**
```bash
$ cat /etc/config/network
config interface 'loopback'
option device 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd8f:41b4:f826::/48'
config device 'br_lan'
option name 'br-lan'
option type 'bridge'
list ports 'eth1'
list ports 'eth3'
option multicast_to_unicast '0'
option macaddr '44:D4:37:71:B5:51'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
option is_lan '1'
option macaddr '44:D4:37:71:B5:51'
config interface 'wan'
option macaddr '44:D4:37:71:B5:52'
option device 'eth4'
option proto 'pppoe'
option username 'test'
option password 'test'
```
- **TR-181 Data Model**
```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.PPP.Interface.1
$ obuspa -c get Device.PPP.Interface.*.LowerLayers
Device.PPP.Interface.1.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface =>
$ obuspa -c get Device.DHCPv6.Client.*.Interface
Device.DHCPv6.Client.1.Interface =>
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Ethernet.Interface.3
```
### 14. Switch WAN connection from PPP to Static
- **TR-181 Commands**
```bash
obuspa -c set Device.IP.Interface.2.LowerLayers ""
obuspa -c del Device.PPP.Interface.1
obuspa -c set Device.IP.Interface.2.LowerLayers Device.Ethernet.Link.2
obuspa -c set Device.IP.Interface.2.Enable 1
obuspa -c add Device.IP.Interface.2.IPv4Address.
obuspa -c set Device.IP.Interface.2.IPv4Address.1.Enable 1
obuspa -c set Device.IP.Interface.2.IPv4Address.1.IPAddress 10.100.1.222
obuspa -c set Device.IP.Interface.2.IPv4Address.1.SubnetMask 255.255.255.0
obuspa -c add Device.IP.Interface.2.IPv4Address.
obuspa -c set Device.IP.Interface.2.IPv4Address.2.Enable 1
obuspa -c set Device.IP.Interface.2.IPv4Address.2.IPAddress 10.100.10.222
obuspa -c set Device.IP.Interface.2.IPv4Address.2.SubnetMask 255.255.255.0
```
- **Network UCI Config**
```bash
$ cat /etc/config/network
config interface 'loopback'
option device 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd8f:41b4:f826::/48'
config device 'br_lan'
option name 'br-lan'
option type 'bridge'
list ports 'eth1'
list ports 'eth3'
option multicast_to_unicast '0'
option macaddr '44:D4:37:71:B5:51'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
option is_lan '1'
option macaddr '44:D4:37:71:B5:51'
config interface 'wan'
option macaddr '44:D4:37:71:B5:52'
option proto 'none'
option device 'eth4'
option disabled '0'
config interface 'iface2_ipv4_1'
option device 'eth4'
option proto 'static'
option disabled '0'
option ipaddr '10.100.1.222'
option netmask '255.255.255.0'
option macaddr '44:D4:37:71:B5:53'
config interface 'iface2_ipv4_2'
option device 'eth4'
option proto 'static'
option disabled '0'
option ipaddr '10.100.10.222'
option netmask '255.255.255.0'
option macaddr '44:D4:37:71:B5:54'
```
- **TR-181 Data Model**
```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.PPP.Interface.*.LowerLayers
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface =>
$ obuspa -c get Device.DHCPv6.Client.*.Interface
Device.DHCPv6.Client.1.Interface =>
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.IP.Interface.2.IPv4Address.
Device.IP.Interface.2.IPv4Address.1.Enable => 1
Device.IP.Interface.2.IPv4Address.1.Status => Enabled
Device.IP.Interface.2.IPv4Address.1.Alias => cpe-1
Device.IP.Interface.2.IPv4Address.1.IPAddress => 10.100.1.222
Device.IP.Interface.2.IPv4Address.1.SubnetMask => 255.255.255.0
Device.IP.Interface.2.IPv4Address.1.AddressingType => Static
Device.IP.Interface.2.IPv4Address.2.Enable => 1
Device.IP.Interface.2.IPv4Address.2.Status => Enabled
Device.IP.Interface.2.IPv4Address.2.Alias => cpe-2
Device.IP.Interface.2.IPv4Address.2.IPAddress => 10.100.10.222
Device.IP.Interface.2.IPv4Address.2.SubnetMask => 255.255.255.0
Device.IP.Interface.2.IPv4Address.2.AddressingType => Static
```
### 15. Switch WAN connection from Static to DHCP
- **TR-181 Commands**
```bash
obuspa -c del Device.IP.Interface.2.IPv4Address.1
obuspa -c del Device.IP.Interface.2.IPv4Address.2
obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.2
obuspa -c set Device.DHCPv6.Client.1.Interface Device.IP.Interface.2
```
- **Network UCI Config**
```bash
$ cat /etc/config/network
config interface 'loopback'
option device 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd8f:41b4:f826::/48'
config device 'br_lan'
option name 'br-lan'
option type 'bridge'
list ports 'eth1'
list ports 'eth3'
option multicast_to_unicast '0'
option macaddr '44:D4:37:71:B5:51'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
option is_lan '1'
option macaddr '44:D4:37:71:B5:51'
config interface 'wan'
option macaddr '44:D4:37:71:B5:52'
option device 'eth4'
option disabled '0'
option proto 'dhcp'
option vendorid 'dslforum.org'
option hostname 'eagle-44d43771b550'
option sendopts '125:00000DE91C0106343444343337020B593037323131343030383603054541474C45'
option reqopts '43 125'
config interface 'wan6'
option device 'eth4'
option proto 'dhcpv6'
option macaddr '44:D4:37:71:B5:52'
```
- **TR-181 Data Model**
```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.PPP.Interface.*.LowerLayers
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.2
$ obuspa -c get Device.DHCPv6.Client.*.Interface
Device.DHCPv6.Client.1.Interface => Device.IP.Interface.2
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Ethernet.Interface.3
```
### 16. Switch WAN connection from DHCP to Static
- **TR-181 Commands**
```bash
obuspa -c set Device.DHCPv4.Client.1.Interface ""
obuspa -c set Device.DHCPv6.Client.1.Interface ""
obuspa -c add Device.IP.Interface.2.IPv4Address.
obuspa -c set Device.IP.Interface.2.IPv4Address.1.Enable 1
obuspa -c set Device.IP.Interface.2.IPv4Address.1.IPAddress 10.100.1.222
obuspa -c set Device.IP.Interface.2.IPv4Address.1.SubnetMask 255.255.255.0
obuspa -c add Device.IP.Interface.2.IPv4Address.
obuspa -c set Device.IP.Interface.2.IPv4Address.2.Enable 1
obuspa -c set Device.IP.Interface.2.IPv4Address.2.IPAddress 10.100.10.222
obuspa -c set Device.IP.Interface.2.IPv4Address.2.SubnetMask 255.255.255.0
```
- **Network UCI Config**
```bash
$ cat /etc/config/network
config interface 'loopback'
option device 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd8f:41b4:f826::/48'
config device 'br_lan'
option name 'br-lan'
option type 'bridge'
list ports 'eth1'
list ports 'eth3'
option multicast_to_unicast '0'
option macaddr '44:D4:37:71:B5:51'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
option is_lan '1'
option macaddr '44:D4:37:71:B5:51'
config interface 'wan'
option macaddr '44:D4:37:71:B5:52'
option device 'eth4'
option disabled '0'
option proto 'none'
config interface 'iface2_ipv4_1'
option device 'eth4'
option proto 'static'
option disabled '0'
option ipaddr '10.100.1.222'
option netmask '255.255.255.0'
option macaddr '44:D4:37:71:B5:53'
config interface 'iface2_ipv4_2'
option device 'eth4'
option proto 'static'
option disabled '0'
option ipaddr '10.100.10.222'
option netmask '255.255.255.0'
option macaddr '44:D4:37:71:B5:54'
```
- **TR-181 Data Model**
```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.PPP.Interface.*.LowerLayers
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface =>
$ obuspa -c get Device.DHCPv6.Client.*.Interface
Device.DHCPv6.Client.1.Interface =>
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.IP.Interface.2.IPv4Address.
Device.IP.Interface.2.IPv4Address.1.Enable => 1
Device.IP.Interface.2.IPv4Address.1.Status => Enabled
Device.IP.Interface.2.IPv4Address.1.Alias => cpe-1
Device.IP.Interface.2.IPv4Address.1.IPAddress => 10.100.1.222
Device.IP.Interface.2.IPv4Address.1.SubnetMask => 255.255.255.0
Device.IP.Interface.2.IPv4Address.1.AddressingType => Static
Device.IP.Interface.2.IPv4Address.2.Enable => 1
Device.IP.Interface.2.IPv4Address.2.Status => Enabled
Device.IP.Interface.2.IPv4Address.2.Alias => cpe-2
Device.IP.Interface.2.IPv4Address.2.IPAddress => 10.100.10.222
Device.IP.Interface.2.IPv4Address.2.SubnetMask => 255.255.255.0
Device.IP.Interface.2.IPv4Address.2.AddressingType => Static
```
### 17. Switch WAN connection from Static to PPP
- **TR-181 Commands**
```bash
obuspa -c del Device.IP.Interface.2.IPv4Address.1
obuspa -c del Device.IP.Interface.2.IPv4Address.2
obuspa -c set Device.IP.Interface.2.LowerLayers ""
obuspa -c add Device.PPP.Interface.
obuspa -c set Device.PPP.Interface.1.LowerLayers Device.Ethernet.Link.2
obuspa -c set Device.PPP.Interface.1.Username test
obuspa -c set Device.PPP.Interface.1.Password test
obuspa -c set Device.PPP.Interface.1.Enable 1
obuspa -c set Device.IP.Interface.2.LowerLayers Device.PPP.Interface.1
```
- **Network UCI Config**
```bash
$ cat /etc/config/network
config interface 'loopback'
option device 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd8f:41b4:f826::/48'
config device 'br_lan'
option name 'br-lan'
option type 'bridge'
list ports 'eth1'
list ports 'eth3'
option multicast_to_unicast '0'
option macaddr '44:D4:37:71:B5:51'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
option is_lan '1'
option macaddr '44:D4:37:71:B5:51'
config interface 'wan'
option macaddr '44:D4:37:71:B5:52'
option disabled '0'
option device 'eth4'
option proto 'pppoe'
option username 'test'
option password 'test'
```
- **TR-181 Data Model**
```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.PPP.Interface.1
$ obuspa -c get Device.PPP.Interface.*.LowerLayers
Device.PPP.Interface.1.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface =>
$ obuspa -c get Device.DHCPv6.Client.*.Interface
Device.DHCPv6.Client.1.Interface =>
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Ethernet.Interface.3
```
### 18. Switch WAN connection from PPP to DHCP
- **TR-181 Commands**
```bash
obuspa -c set Device.IP.Interface.2.LowerLayers ""
obuspa -c del Device.PPP.Interface.1
obuspa -c set Device.IP.Interface.2.LowerLayers Device.Ethernet.Link.2
obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.2
obuspa -c set Device.DHCPv6.Client.1.Interface Device.IP.Interface.2
```
- **Network UCI Config**
```bash
$ cat /etc/config/network
config interface 'loopback'
option device 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd8f:41b4:f826::/48'
config device 'br_lan'
option name 'br-lan'
option type 'bridge'
list ports 'eth1'
list ports 'eth3'
option multicast_to_unicast '0'
option macaddr '44:D4:37:71:B5:51'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
option is_lan '1'
option macaddr '44:D4:37:71:B5:51'
config interface 'wan'
option macaddr '44:D4:37:71:B5:52'
option disabled '0'
option device 'eth4'
option proto 'dhcp'
option vendorid 'dslforum.org'
option hostname 'eagle-44d43771b550'
option sendopts '125:00000DE91C0106343444343337020B593037323131343030383603054541474C45'
option reqopts '43 125'
config interface 'wan6'
option device 'eth4'
option proto 'dhcpv6'
option macaddr '44:D4:37:71:B5:52'
```
- **TR-181 Data Model**
```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.Link.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.Link.2
$ obuspa -c get Device.PPP.Interface.*.LowerLayers
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.2
$ obuspa -c get Device.DHCPv6.Client.*.Interface
Device.DHCPv6.Client.1.Interface => Device.IP.Interface.2
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Bridging.Bridge.1.Port.1
Device.Ethernet.Link.2.LowerLayers => Device.Ethernet.Interface.3
```
## Limitations
- Regarding above scenarios, it's better to follow the sequence as described in each scenario to avoid misconfiguration issues

View file

@ -1208,12 +1208,20 @@ static int delObjDHCPv4Client(char *refparam, struct dmctx *ctx, void *data, cha
dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dmmap_s, "dhcp_client_key", &dhcp_client_key);
if (((struct dhcp_client_args *)data)->iface_s) {
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "proto", "none");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "clientid", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "vendorid", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "hostname", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "sendopts", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "reqopts", "");
char *ip_instance = NULL;
struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(((struct dhcp_client_args *)data)->iface_s));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (dmmap_s && DM_STRLEN(ip_instance) == 0) {
dmuci_delete_by_section(((struct dhcp_client_args *)data)->iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "proto", "none");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "clientid", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "vendorid", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "hostname", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "sendopts", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "reqopts", "");
}
}
uci_path_foreach_option_eq_safe(bbfdm, "dmmap_dhcp_client", "send_option", "dhcp_client_key", dhcp_client_key, stmp, s) {
@ -1238,12 +1246,20 @@ static int delObjDHCPv4Client(char *refparam, struct dmctx *ctx, void *data, cha
get_config_section_of_dmmap_section("network", "interface", iface_name, &iface_s);
if (iface_s) {
dmuci_set_value_by_section(iface_s, "proto", "none");
dmuci_set_value_by_section(s, "clientid", "");
dmuci_set_value_by_section(s, "vendorid", "");
dmuci_set_value_by_section(s, "hostname", "");
dmuci_set_value_by_section(s, "sendopts", "");
dmuci_set_value_by_section(s, "reqopts", "");
char *ip_instance = NULL;
struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(iface_s));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (dmmap_s && DM_STRLEN(ip_instance) == 0) {
dmuci_delete_by_section(iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(iface_s, "proto", "none");
dmuci_set_value_by_section(iface_s, "clientid", "");
dmuci_set_value_by_section(iface_s, "vendorid", "");
dmuci_set_value_by_section(iface_s, "hostname", "");
dmuci_set_value_by_section(iface_s, "sendopts", "");
dmuci_set_value_by_section(iface_s, "reqopts", "");
}
}
uci_path_foreach_option_eq_safe(bbfdm, "dmmap_dhcp_client", "send_option", "dhcp_client_key", dhcp_client_key, sstmp, ss) {
@ -2343,29 +2359,58 @@ static int set_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *d
adm_entry_get_linker_value(ctx, value, &linker);
if (dhcpv4_client->iface_s) {
dmuci_set_value_by_section(dhcpv4_client->iface_s, "proto", "none");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "clientid", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "vendorid", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "hostname", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "sendopts", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "reqopts", "");
char *ip_instance = NULL;
struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(dhcpv4_client->iface_s));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (dmmap_s && DM_STRLEN(ip_instance) == 0) {
dmuci_delete_by_section(dhcpv4_client->iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(dhcpv4_client->iface_s, "proto", "none");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "clientid", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "vendorid", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "hostname", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "sendopts", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "reqopts", "");
}
}
if (!linker || *linker == 0) {
dmuci_set_value_by_section_bbfdm(dhcpv4_client->dmmap_s, "iface_name", "");
} else {
// Update iface_name option
dmuci_set_value_by_section_bbfdm(dhcpv4_client->dmmap_s, "iface_name", linker ? linker : "");
if (DM_STRLEN(linker)) {
struct uci_section *interface_s = NULL;
char *curr_proto = NULL;
get_config_section_of_dmmap_section("network", "interface", linker, &interface_s);
if (interface_s == NULL)
return FAULT_9007;
// Get the current proto
dmuci_get_value_by_section_string(interface_s, "proto", &curr_proto);
if (DM_STRCMP(curr_proto, "dhcpv6") == 0) {
// There is a DHCPv6 Client map to this interface section, therefore create a new interface section
char *curr_device = NULL;
char buf[32] = {0};
snprintf(buf, sizeof(buf), "%s4", section_name(interface_s));
// Get the current device
dmuci_get_value_by_section_string(interface_s, "device", &curr_device);
dmuci_add_section("network", "interface", &interface_s);
dmuci_rename_section_by_section(interface_s, buf);
// Update device option
dmuci_set_value_by_section(interface_s, "device", curr_device);
// Update iface_name option
dmuci_set_value_by_section_bbfdm(dhcpv4_client->dmmap_s, "iface_name", buf);
}
// Update proto option of config section
dmuci_set_value_by_section(interface_s, "proto", "dhcp");
// Update dmmap section
dmuci_set_value_by_section_bbfdm(dhcpv4_client->dmmap_s, "iface_name", linker);
dmuci_get_value_by_section_string(dhcpv4_client->dmmap_s, "dhcp_client_key", &dhcp_client_key);
if (!DM_STRLEN(dhcp_client_key))
break;
@ -2376,6 +2421,7 @@ static int set_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *d
// Added the enabled options for reqopts
create_dhcp_req_option_list(interface_s, dhcp_client_key);
}
break;
}
return 0;

View file

@ -345,10 +345,18 @@ static int delObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, cha
dmuci_delete_by_section(((struct dhcpv6_client_args *)data)->dmmap_s, NULL, NULL);
if (((struct dhcpv6_client_args *)data)->iface_s) {
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "proto", "none");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqaddress", "");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqprefix", "");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqopts", "");
char *ip_instance = NULL;
struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(((struct dhcpv6_client_args *)data)->iface_s));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (dmmap_s && DM_STRLEN(ip_instance) == 0) {
dmuci_delete_by_section(((struct dhcpv6_client_args *)data)->iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "proto", "none");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqaddress", "");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqprefix", "");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqopts", "");
}
}
break;
case DEL_ALL:
@ -361,10 +369,18 @@ static int delObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, cha
get_config_section_of_dmmap_section("network", "interface", iface_name, &iface_s);
if (iface_s) {
dmuci_set_value_by_section(iface_s, "proto", "none");
dmuci_set_value_by_section(iface_s, "reqaddress", "");
dmuci_set_value_by_section(iface_s, "reqprefix", "");
dmuci_set_value_by_section(iface_s, "reqopts", "");
char *ip_instance = NULL;
struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(iface_s));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (dmmap_s && DM_STRLEN(ip_instance) == 0) {
dmuci_delete_by_section(iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(iface_s, "proto", "none");
dmuci_set_value_by_section(iface_s, "reqaddress", "");
dmuci_set_value_by_section(iface_s, "reqprefix", "");
dmuci_set_value_by_section(iface_s, "reqopts", "");
}
}
dmuci_delete_by_section(s, NULL, NULL);
@ -568,16 +584,26 @@ static int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *d
adm_entry_get_linker_value(ctx, value, &linker);
if (dhcpv6_client->iface_s) {
dmuci_set_value_by_section(dhcpv6_client->iface_s, "proto", "none");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqaddress", "");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqprefix", "");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqopts", "");
char *ip_instance = NULL;
struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(dhcpv6_client->iface_s));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (dmmap_s && DM_STRLEN(ip_instance) == 0) {
dmuci_delete_by_section(dhcpv6_client->iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(dhcpv6_client->iface_s, "proto", "none");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqaddress", "");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqprefix", "");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqopts", "");
}
}
if (!linker || *linker == 0) {
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "iface_name", "");
} else {
// Update iface_name option
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "iface_name", linker ? linker : "");
if (DM_STRLEN(linker)) {
struct uci_section *interface_s = NULL;
char *curr_proto = NULL;
char *reqaddress = NULL;
char *reqprefix = NULL;
char *reqopts = NULL;
@ -586,12 +612,31 @@ static int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *d
if (interface_s == NULL)
return FAULT_9007;
// Get the current proto
dmuci_get_value_by_section_string(interface_s, "proto", &curr_proto);
if (DM_STRCMP(curr_proto, "dhcp") == 0) {
// There is a DHCPv4 Client map to this interface section, therefore create a new interface section
char *curr_device = NULL;
char buf[32] = {0};
snprintf(buf, sizeof(buf), "%s6", section_name(interface_s));
// Get the current device
dmuci_get_value_by_section_string(interface_s, "device", &curr_device);
dmuci_add_section("network", "interface", &interface_s);
dmuci_rename_section_by_section(interface_s, buf);
// Update device option
dmuci_set_value_by_section(interface_s, "device", curr_device);
// Update iface_name option
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "iface_name", buf);
}
// Update proto option of config section
dmuci_set_value_by_section(interface_s, "proto", "dhcpv6");
// Update dmmap section
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "iface_name", linker);
// Get the current value of requested parameters
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "reqaddress", &reqaddress);
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "reqprefix", &reqprefix);

View file

@ -132,7 +132,7 @@ static void dmmap_synchronizeEthernetLink(struct dmctx *dmctx, DMNODE *parent_no
// Skip this interface section if its device starts with prfix 'link_'
dmuci_get_value_by_section_string(s, "device", &device);
if (DM_STRNCMP(device, "link_", 5) == 0 || DM_STRNCMP(device, "iface", 5) == 0)
if (DM_STRNCMP(device, "link_", 5) == 0 || strcmp(device, section_name(s)) == 0)
continue;
// Skip this interface section if its device is empty

View file

@ -49,7 +49,7 @@ void ppp___update_sections(struct uci_section *s_from, struct uci_section *s_to)
void ppp___reset_options(struct uci_section *ppp_s)
{
dmuci_set_value_by_section(ppp_s, "device", "");
dmuci_set_value_by_section(ppp_s, "device", section_name(ppp_s));
dmuci_set_value_by_section(ppp_s, "username", "");
dmuci_set_value_by_section(ppp_s, "password", "");
dmuci_set_value_by_section(ppp_s, "pppd_options", "");