OLSR / OONF

OLSR.org Network Framework - olsrd v2 / DLEP
55 stars 36 forks source link

dlep_router datapath_if not honored for session tcp connection #41

Closed XDjackieXD closed 1 day ago

XDjackieXD commented 2 years ago

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 commented 1 year ago

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 commented 1 year ago

@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.

XDjackieXD commented 1 year ago

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

XDjackieXD commented 1 year ago

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

XDjackieXD commented 1 year ago

@mathiashro could you please merge the PR?

mathiashro commented 1 day ago

PR #55 has been merged.