Modify

Opened 3 years ago

Closed 3 years ago

#19116 closed defect (not_a_bug)

"/lib/functions/network.sh; network_get_device" returns empty

Reported by: n0nb@… Owned by: developers
Priority: normal Milestone:
Component: packages Version: Barrier Breaker 14.07
Keywords: Cc:

Description

I ran into this when I was setting up vnstat on my Asus WL-500GP v2. The recipe calls for running the following commands:

. /lib/functions/network.sh; network_get_device if_wan wan
vnstat -u -i $if_wan

However, doing so results in empty output which can be seen as:

root@wzh600dhp:~# . /lib/functions/network.sh; network_get_device if_wan wan; echo $if_wan

root@wzh600dhp:~# 

I have seen this exact behavior on two Barrier Breaker installations, one an Asus WL-500GP v2 (brcm47xx) and the other a Buffalo WZR-600DHP (ar71xx) so I suspect something had changed with the /lib/functions/network.sh script.

For reference, this is a copy of a post in the forum to which I received no replies:

https://forum.openwrt.org/viewtopic.php?id=56140

Attachments (0)

Change History (5)

comment:1 follow-up: Changed 3 years ago by yousong

You may want to consult the output of command ubus call network.interface.wan status. Besides network_get_device which will retrieve l3 device name, there is also network_get_physdev for l2 device.

comment:2 follow-up: Changed 3 years ago by Nilfred

Worksforme

. /lib/functions/network.sh; if network_get_device if_wan wan; then echo $if_wan; fi
pppoe-wan

Try this:

. /lib/functions/network.sh; if network_is_up wan; then echo WAN is up; else echo WAN is down; fi

comment:3 in reply to: ↑ 1 Changed 3 years ago by n0nb@…

Replying to yousong:

You may want to consult the output of command ubus call network.interface.wan status. Besides network_get_device which will retrieve l3 device name, there is also network_get_physdev for l2 device.

The issue I am trying to report is that the network_get_device function returns nothing on my two installations, not that I couldn't figure out the physical name of the WAN port. Sorry if I was unclear.

I'm not sure if this is intended to be a universal function but when I looked at its definition my understanding is that looking to match a string with ".interface" in it, although I could be wrong.

BTW, network_get_physdev does return the proper physical device for my WAN port. I may add this alternate command the Wiki recipe page.

comment:4 in reply to: ↑ 2 Changed 3 years ago by n0nb@…

Replying to Nilfred:

Worksforme

. /lib/functions/network.sh; if network_get_device if_wan wan; then echo $if_wan; fi
pppoe-wan

Now, this does work and returns the correct device, eth0.2 in the case of my router. Hmmmm.

Try this:

. /lib/functions/network.sh; if network_is_up wan; then echo WAN is up; else echo WAN is down; fi

That works as well, returning "WAN is up".

After a bit more testing, the original command I reported on is working fine. I originally had tried the command when I was setting up the router and the WAN port was not connected to a network. Now that it is on line the command works, so the caveat is that the function can only report the interface when it is active.

My apologies for wasting everyone's time. This report may be closed. I will link to this in my forum post and may add a note to the Wiki recipe page.

Thanks, Nate.

comment:5 Changed 3 years ago by jow

  • Resolution set to not_a_bug
  • Status changed from new to closed

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.