openthread / ot-br-posix

OpenThread Border Router, a Thread border router for POSIX-based platforms.
https://openthread.io/
BSD 3-Clause "New" or "Revised" License
418 stars 232 forks source link

Bug in dbus getall method read failure #2414

Open yf-fan-org opened 2 months ago

yf-fan-org commented 2 months ago

command: sudo gdbus call --system \ --dest io.openthread.BorderRouter.wpan0 \ --object-path /io/openthread/BorderRouter/wpan0 \ --method org.freedesktop.DBus.Properties.GetAll \ "io.openthread.BorderRouter"

1、Dbus log: method call time=1722911624.010217 sender=:1.7 -> destination=io.openthread.BorderRouter.wpan0 serial=3 path=/io/openthread/BorderRouter/wpan0; interface=org.freedesktop.DBus.Properties; member=GetAll string "io.openthread.BorderRouter" error time=1722911624.010249 sender=:1.4 -> destination=:1.7 error_name=io.openthread.Error.NotImplemented reply_serial=3

2、otbr log: ubuntu@raspberrypi:~$ sudo journalctl -u otbr-agent.service -f [sudo] password for ubuntu: Aug 06 02:38:04 raspberrypi otbr-agent[69324]: 20:42:17.125 [I] MeshForwarder-: src:[fe80:0:0:0:3c63:d052:1e9a:b8e9]:19788 Aug 06 02:38:04 raspberrypi otbr-agent[69324]: 20:42:17.126 [I] MeshForwarder-: dst:[ff02:0:0:0:0:0:0:1]:19788 Aug 06 02:38:16 raspberrypi otbr-agent[69324]: 20:42:29.214 [I] Mle-----------: Send Advertisement (ff02:0:0:0:0:0:0:1) Aug 06 02:38:16 raspberrypi otbr-agent[69324]: 20:42:29.220 [I] MeshForwarder-: Sent IPv6 UDP msg, len:91, chksum:9f33, ecn:no, to:0xffff, sec:no, prio:net Aug 06 02:38:16 raspberrypi otbr-agent[69324]: 20:42:29.220 [I] MeshForwarder-: src:[fe80:0:0:0:3c63:d052:1e9a:b8e9]:19788 Aug 06 02:38:16 raspberrypi otbr-agent[69324]: 20:42:29.220 [I] MeshForwarder-: dst:[ff02:0:0:0:0:0:0:1]:19788 Aug 06 02:38:19 raspberrypi otbr-agent[69324]: 20:42:32.350 [I] MeshForwarder-: Received IPv6 UDP msg, len:83, chksum:3fcf, ecn:no, from:4a7ccb61bb6143a7, sec:no, prio:net, rss:-24.0 Aug 06 02:38:19 raspberrypi otbr-agent[69324]: 20:42:32.350 [I] MeshForwarder-: src:[fe80:0:0:0:487c:cb61:bb61:43a7]:19788 Aug 06 02:38:19 raspberrypi otbr-agent[69324]: 20:42:32.350 [I] MeshForwarder-: dst:[ff02:0:0:0:0:0:0:1]:19788 Aug 06 02:38:19 raspberrypi otbr-agent[69324]: 20:42:32.351 [I] Mle-----------: Receive Announce (fe80:0:0:0:487c:cb61:bb61:43a7)

Aug 06 02:38:25 raspberrypi otbr-agent[69324]: [ERR ]-UTILS---: Replied to org.freedesktop.DBus.Properties.GetAll with result io.openthread.Error.NotImplemented Aug 06 02:38:25 raspberrypi otbr-agent[69324]: 20:42:38.768 [I] MeshForwarder-: Received IPv6 UDP msg, len:91, chksum:efa2, ecn:no, from:4a7ccb61bb6143a7, sec:no, prio:net, rss:-24.0 Aug 06 02:38:25 raspberrypi otbr-agent[69324]: 20:42:38.769 [I] MeshForwarder-: src:[fe80:0:0:0:487c:cb61:bb61:43a7]:19788 Aug 06 02:38:25 raspberrypi otbr-agent[69324]: 20:42:38.769 [I] MeshForwarder-: dst:[ff02:0:0:0:0:0:0:1]:19788 Aug 06 02:38:25 raspberrypi otbr-agent[69324]: 20:42:38.769 [I] Mle-----------: Receive Advertisement (fe80:0:0:0:487c:cb61:bb61:43a7,0x1000) Aug 06 02:38:29 raspberrypi otbr-agent[69324]: 20:42:41.820 [I] Mle-----------: Send Advertisement (ff02:0:0:0:0:0:0:1) Aug 06 02:38:29 raspberrypi otbr-agent[69324]: 20:42:41.827 [I] MeshForwarder-: Sent IPv6 UDP msg, len:91, chksum:9b06, ecn:no, to:0xffff, sec:no, prio:net Aug 06 02:38:29 raspberrypi otbr-agent[69324]: 20:42:41.827 [I] MeshForwarder-: src:[fe80:0:0:0:3c63:d052:1e9a:b8e9]:19788 Aug 06 02:38:29 raspberrypi otbr-agent[69324]: 20:42:41.827 [I] MeshForwarder-: dst:[ff02:0:0:0:0:0:0:1]:19788

yf-fan-org commented 2 months ago

@superwhd pls help, thanks

yf-fan-org commented 2 months ago

How should I set it up to fix this?

superwhd commented 2 months ago

This seems to be an existing issue: https://github.com/openthread/ot-br-posix/issues/2133

@morningboata I wonder if this has been fixed or not?

Regarding this one, @yf-fan-org you may try getting the properties you're interested in (this should work) instead of getting all properties.

morningboata commented 2 months ago

2133 is not fixed. Added a comment in it.

yf-fan-org commented 2 months ago

This seems to be an existing issue: #2133

@morningboata I wonder if this has been fixed or not?

Regarding this one, @yf-fan-org you may try getting the properties you're interested in (this should work) instead of getting all properties.

@superwhd Thank you very much, mainly because I need to be able to get all the properties when initializing so that I can read the data in the cache next time, is there any way I can make get all work? It's too much trouble for me to read them one by one.

yf-fan-org commented 2 months ago

image

I've tried to turn on attribute configurations that may not be turned on, but I still get the same error, all attributes should be supported at this time @superwhd

superwhd commented 2 months ago

I was trying to fix the issue by abandoning the opened container on error but otbr-agent crashed after handling the message. The client also failed to receive the response:

    for (auto &p : mGetPropertyHandlers.at(interfaceName))
    {
        DBusMessageIter subIter, dictEntryIter;

        VerifyOrExit(dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
                                                      "{" DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING "}",
                                                      &subIter),
                     error = OT_ERROR_FAILED);
        VerifyOrExit(dbus_message_iter_open_container(&subIter, DBUS_TYPE_DICT_ENTRY, nullptr, &dictEntryIter),
                     error = OT_ERROR_FAILED);
        VerifyOrExit(DBusMessageEncode(&dictEntryIter, p.first) == OTBR_ERROR_NONE, error = OT_ERROR_FAILED);

->        if (p.second(dictEntryIter) != OT_ERROR_NONE) {
->           dbus_message_iter_abandon_container_if_open(&subIter, &dictEntryIter);
->           dbus_message_iter_abandon_container_if_open(&iter, &subIter);
->           continue;
        }

        VerifyOrExit(dbus_message_iter_close_container(&subIter, &dictEntryIter), error = OT_ERROR_FAILED);
        VerifyOrExit(dbus_message_iter_close_container(&iter, &subIter));
    }
caipiblack commented 1 month ago

Wow! I come in the issues section for the same thing. But it seems that many issues exists.

What is the status of this issue or related issues ? What is the status of the DBUS-API ?

Some logs

Command 1:

Logs of the command:

# busctl --system --verbose introspect io.openthread.BorderRouter.wpan0 /io/openthread/BorderRouter/wpan0
Failed to get all properties on interface io.openthread.BorderRouter: Input/output error

Logs of otbr-agent:

Sep  3 11:02:05 otbr-agent[23172]: [INFO]-DBUS----: Handling method org.freedesktop.DBus.Introspectable.Introspect
Sep  3 11:02:05 otbr-agent[23172]: [INFO]-DBUS----: Handling method org.freedesktop.DBus.Properties.GetAll
Sep  3 11:02:05 otbr-agent[23172]: [ERR ]-UTILS---: Replied to org.freedesktop.DBus.Properties.GetAll with result io.openthread.Error.NotImplemented

Command 2:

Logs of the command:

# dbus-send --system --print-reply --dest=io.openthread.BorderRouter.wpan0 /io/openthread/BorderRouter/wpan0 org.freedesktop.DBus.Properties.GetAll string:"io.openthread.BorderRouter"
Error io.openthread.Error.NotImplemented: io.openthread.Error.NotImplemented

Logs of otbr-agent:

Sep  3 11:32:15 otbr-agent[23172]: [INFO]-DBUS----: Handling method org.freedesktop.DBus.Properties.GetAll
Sep  3 11:32:15 otbr-agent[23172]: [ERR ]-UTILS---: Replied to org.freedesktop.DBus.Properties.GetAll with result io.openthread.Error.NotImplemented

I have OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE disabled, but I think the error can't be there, because when this macro is disabled, the handlers are not registered so they can't be called.

So maybe there is something else that returns "not implemented". (https://github.com/openthread/ot-br-posix/issues/2133#issuecomment-2326043195)

superwhd commented 1 month ago

What is the status of the DBUS-API ?

D-BUS API will be continuously maintained but the priorities of the methods may vary, depending on the use cases.

So far the introspect.xml is the most comprehensive documentation in the repo. I wonder what kind of documentation would you suggest?

caipiblack commented 1 month ago

What is the status of the DBUS-API ?

D-BUS API will be continuously maintained but the priorities of the methods may vary, depending on the use cases.

So far the introspect.xml is the most comprehensive documentation in the repo. I wonder what kind of documentation would you suggest?

I was thinking about something like this directly in openthread website: https://w1.fi/wpa_supplicant/devel/dbus.html

So that everybody know there is a DBUS API and how to use.

But in any cases, it will be (maybe) the same informations as introspect.xml, eventually with some dbus-send examples.

Edit: i am happy to ear that DBUS is continuously improved, so i am in the good direction.