Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dlep_router datapath_if not honored for session tcp connection #41

Closed
XDjackieXD opened this issue Jul 8, 2022 · 6 comments
Closed

Comments

@XDjackieXD
Copy link

When trying to run DLEP information out of band (so you don't have to use ebtables) it is impossible to get the dlep_router to actually try the session connection on the interface specified by datapath_if.
It correctly uses the datapath_if for the UDP discovery but then tries to connect to the discovered dlep_radio on the "main" interface instead of the datapath_if...
Even using non-link-local IPv4 addresses with connect_to doesn't work as the connect syscall seems to have the interface specified.

When setting the datapath interface as the "main" interface for dlep_router, this leads to it correctly connecting to dlep_radio and getting all the l2 info but not using them for the real "main" interface but showing a new interface in olsrd2 layer2info interface.

Example output when using the datapath interface as "main" interface for the dlep_router config (eth4.255 should have all the l2 info now displayed as a new interface eth4.254):

{
  "interface": [
    {
      "if": "eth4.254",
      "if_index": 39,
      "if_local_addr": "f4:92:bf:ab:f1:ab",
      "if_type": "wireless",
      "if_dlep": "true",
      "if_ident": "",
      "if_ident_addr": "",
      "if_lastseen": 0,
      "if_frequency1": "5.5GHz",
      "if_frequency2": "0Hz",
      "if_bandwidth1": "20MHz",
      "if_bandwidth2": "0Hz",
      "if_noise": "-95dBm",
      "if_ch_active": "6.548ks",
      "if_ch_busy": "1.446ks",
      "if_ch_rx": "1.465ks",
      "if_ch_tx": "348ms",
      "if_mtu": "0byte",
      "if_mcs_by_probing": "true",
      "if_rx_only_unicast": "false",
      "if_tx_only_unicast": "false",
      "if_frequency1_origin": "dlep router",
      "if_frequency2_origin": "",
      "if_bandwidth1_origin": "dlep router",
      "if_bandwidth2_origin": "",
      "if_noise_origin": "dlep router",
      "if_ch_active_origin": "dlep router",
      "if_ch_busy_origin": "dlep router",
      "if_ch_rx_origin": "dlep router",
      "if_ch_tx_origin": "dlep router",
      "if_mtu_origin": "",
      "if_mcs_by_probing_origin": "dlep router",
      "if_rx_only_unicast_origin": "",
      "if_tx_only_unicast_origin": ""
    },
    {
      "if": "eth4.255",
      "if_index": 21,
      "if_local_addr": "f4:92:bf:ab:f1:ab",
      "if_type": "wireless",
      "if_dlep": "false",
      "if_ident": "",
      "if_ident_addr": "",
      "if_lastseen": 0,
      "if_frequency1": "0Hz",
      "if_frequency2": "0Hz",
      "if_bandwidth1": "0Hz",
      "if_bandwidth2": "0Hz",
      "if_noise": "0mdBm",
      "if_ch_active": "0ns",
      "if_ch_busy": "0ns",
      "if_ch_rx": "0ns",
      "if_ch_tx": "0ns",
      "if_mtu": "0byte",
      "if_mcs_by_probing": "false",
      "if_rx_only_unicast": "false",
      "if_tx_only_unicast": "false",
      "if_frequency1_origin": "",
      "if_frequency2_origin": "",
      "if_bandwidth1_origin": "",
      "if_bandwidth2_origin": "",
      "if_noise_origin": "",
      "if_ch_active_origin": "",
      "if_ch_busy_origin": "",
      "if_ch_rx_origin": "",
      "if_ch_tx_origin": "",
      "if_mtu_origin": "",
      "if_mcs_by_probing_origin": "",
      "if_rx_only_unicast_origin": "",
      "if_tx_only_unicast_origin": ""
    },
    {
      "if": "lo",
      "if_index": 1,
      "if_local_addr": "00:00:00:00:00:00",
      "if_type": "wireless",
      "if_dlep": "false",
      "if_ident": "",
      "if_ident_addr": "",
      "if_lastseen": 0,
      "if_frequency1": "0Hz",
      "if_frequency2": "0Hz",
      "if_bandwidth1": "0Hz",
      "if_bandwidth2": "0Hz",
      "if_noise": "0mdBm",
      "if_ch_active": "0ns",
      "if_ch_busy": "0ns",
      "if_ch_rx": "0ns",
      "if_ch_tx": "0ns",
      "if_mtu": "0byte",
      "if_mcs_by_probing": "false",
      "if_rx_only_unicast": "false",
      "if_tx_only_unicast": "false",
      "if_frequency1_origin": "",
      "if_frequency2_origin": "",
      "if_bandwidth1_origin": "",
      "if_bandwidth2_origin": "",
      "if_noise_origin": "",
      "if_ch_active_origin": "",
      "if_ch_busy_origin": "",
      "if_ch_rx_origin": "",
      "if_ch_tx_origin": "",
      "if_mtu_origin": "",
      "if_mcs_by_probing_origin": "",
      "if_rx_only_unicast_origin": "",
      "if_tx_only_unicast_origin": ""
    }
  ]
}
@XDjackieXD
Copy link
Author

XDjackieXD commented Feb 5, 2023

A bit of digging later, it seems like this is caused by
https://github.com/OLSR/OONF/blob/master/src/generic/dlep/ext_base_proto/proto_router.c#L293
and
https://github.com/OLSR/OONF/blob/master/src/generic/dlep/ext_base_proto/proto_router.c#L333
using the interface, the dlep router is configured for to set up the TCP session connection, instead of using the datapath_if.
Changing ifdata->index in both lines to use the interface index of datapath_if should fix this (although I'm not quite sure where to get this value in that context).

(so the discovery packet is sent on the correct interface and the offer is received on the correct interface but it then tries to establish the TCP connection on the wrong interface)

@mathiashro
Copy link
Contributor

mathiashro commented Feb 5, 2023

@XDjackieXD Many thanks for providing more research at this topic. Do you don't mind to create a patch, compile it and test it in your environment? I pull request with your tested change is highly appreciated.

@mathiashro mathiashro added the bug label Feb 5, 2023
@XDjackieXD
Copy link
Author

I will prepare a PR. I'd guess you prefer the PR to be against the develop branch?

@XDjackieXD
Copy link
Author

PR is open and seems to be working fine on my OpenWrt setup!

@XDjackieXD
Copy link
Author

@mathiashro could you please merge the PR?

@mathiashro
Copy link
Contributor

PR #55 has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants