miniupnp: miniupnpd-nftables 2.3.0 on OpenWrt 22.03.0: get/deleteportmapping: Wrong results.

I have a Python script running on my PC which checks port forwardings on my router every time a network interface comes up. If the desired forward already exists it does nothing. If for some reason “my” ports are used by another mapping it will be deleted and my mapping will be configured.

In OpenWrt 22.03.0 with miniupnpd-nftables this does not work any more because getgenericportmapping and getspecificportmapping return 0 instead of the actual Client Port number.

Consequently my script wants to delete this “wrong” mapping which does not work either. Nevertheless deleteportmapping returns True.

This leads to one more mapping every time my script runs:

image

Python 3.8.10 (default, Jun 22 2022, 20:18:18) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.


import miniupnpc

u = miniupnpc.UPnP()

u.discover()
1

igd = u.selectigd()
print("IGD: %s", igd)
IGD: %s http://192.168.1.1:5000/ctl/IPConn

u.getgenericportmapping(0)
(55054, 'TCP', ('192.168.1.110', 0), 'some_name', '1', '', 598097)

u.getgenericportmapping(1)
(55054, 'TCP', ('192.168.1.110', 0), 'some_name', '1', '', 598090)

u.getgenericportmapping(2)
(55054, 'TCP', ('192.168.1.110', 0), 'some_name', '1', '', 598083)

u.getgenericportmapping(3)
(55054, 'TCP', ('192.168.1.110', 0), 'some_name', '1', '', 598059)

u.getgenericportmapping(40)
(55054, 'TCP', ('192.168.1.110', 0), 'some_name', '1', '', 597978)

u.getgenericportmapping(41)



u.getspecificportmapping(55054, 'TCP')
('192.168.1.110', 0, 'some_name', True, 597862)

deleteportmapping returns True but does not change the number of mappings:

print(u.deleteportmapping(55054, 'TCP'))
True

u.getgenericportmapping(0)
(55054, 'TCP', ('192.168.1.110', 0), 'some_name', '1', '', 597622)

u.getgenericportmapping(1)
(55054, 'TCP', ('192.168.1.110', 0), 'some_name', '1', '', 597613)


u.getspecificportmapping(55054, 'TCP')
('192.168.1.110', 0, 'some_name', True, 597602)

The only thing that happens is that the “Description” column in Luci now is also empty at the first entry: image

Clicking on the “Delete” button on the right side of one of the mappings without “Description” deletes all mappings without “Description”.

Clicking on the “Delete” button on the right side of the mapping with “Description” deletes all mappings.

/etc/openwrt_release DISTRIB_ID=‘OpenWrt’ DISTRIB_RELEASE=‘22.03.0’ DISTRIB_REVISION=‘r19685-512e76967f’ DISTRIB_TARGET=‘ath79/generic’ DISTRIB_ARCH=‘mips_24kc’ DISTRIB_DESCRIPTION=‘OpenWrt 22.03.0 r19685-512e76967f’ DISTRIB_TAINTS=‘’

miniupnpd --version miniupnpd 2.3.0 Sep 6 2022 using netfilter(nftables) backend

opkg info miniupnpd-nftables Package: miniupnpd-nftables Version: 2022-08-31-68c8ec50-1 Depends: libc, libcap-ng, libmnl0, libuuid1, libnftnl11 Provides: miniupnpd Conflicts: miniupnpd-iptables Status: install ok installed Section: net Architecture: mips_24kc Size: 77892 Filename: miniupnpd-nftables_2022-08-31-68c8ec50-1_mips_24kc.ipk Conffiles: /etc/config/upnpd 2645931c86316c8e46f5f0a6e1e322b2e2fd82cad38be2acca76a8f106892f52 Description: Lightweight UPnP IGD, NAT-PMP & PCP daemon (nftables) Installed-Time: 1662173734

On my Ubuntu 20.04.5 PC I have installed:

miniupnpc 2.1.20190824-0ubuntu2 amd64 UPnP IGD client lightweight library client python3-miniupnpc:amd64 2.1.20190824-0ubuntu2 amd64 UPnP IGD client lightweight library Python 3 bindings

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 36 (22 by maintainers)

Commits related to this issue

Most upvoted comments

@miniupnp nice catch if you give me a few days I can test it

This is interesting. In 26 years of extensive work in ITC I never, ever encountered any problems with little/big endian.

you worked only with developers that carefully avoid such mistakes as de-referencing wrong pointer types 😉

void * p = calloc(16, 1);
*((uint16_t *)p) =  0x1234;
// after that memory pointed by p is 0x12 0x34 on a big endian machine,
// 0x34 0x12 on little endian.
uint32_t a = *((uint32_t *)p);
// a is 0x12340000 on a big endian machine
// a is 0x00001234 on a little endian machine
//  so (uint16_t)a is 0x0000 on a big endian machine (wrong)
// but 0x1234 on a little endian one (OK)