OpenWrt Forum Archive

Topic: luci/view/admin_status: Network IPv6 show Type and "Delegated Prefix"

The content of this topic has been archived on 28 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

On the main status page, the IPv4 Network gives lots of info about the information you got from the ISP's internet. But the IPv6 portion is lacking.

One of the most popular IPv6 is "Prefix Delegation". And currently OpenWRT/LEDE does not display any information about this on the status page. This status page should display the TYPE and the PREFIX DELEGATED from the ISP.


First we need to get the Prefix Delegation information. This information is stored in "ipv6-prefix" variable. Currently luci only get's the "ipv6-address" and "ipv6-prefix-assignment" from the structure. We can do one of two things, we can alter their "ip6addr" function in the network.lua file, so if it doesn't get a ip6addr, it'll look into the "ipv6-prefix". Then the ip6addr will return the ipv6 address, else the ipv6-prefix-assignment, and finally just the ipv6-prefix. Then this will just display on the status page as normal.

/usr/lib/lua/luci/model/network.lua

function protocol.ip6addr(self)
    local addrs = self:_ubus("ipv6-address")
    if addrs and #addrs > 0 then
        return "%s/%d" %{ addrs[1].address, addrs[1].mask }
    else
        addrs = self:_ubus("ipv6-prefix-assignment")
        if addrs and #addrs > 0 then
            return "%s/%d" %{ addrs[1].address, addrs[1].mask }
        else
            addrs = self:_ubus("ipv6-prefix")
            if addrs and #addrs > 0 then
                return "%s/%d" %{ addrs[1].address, addrs[1].mask }
            end
        end
    end
end

Cleaner would be to make a new function protocol.ip6prefix(self), and check this in the admin_status page. If this is empty, do what we do now. If there is a prefix, display it under:

On the luci/view/admin_status/index.htm

Type: dhcpv6-pd
Prefix Delegated: 2001:xxx:xxx:d000::/56


So in summery, IPv6 TYPE should be extracted. If there is a "ipv6-prefix", then "-pd" should be added to the end of type, and you should display the Prefix Delegated. (If Address is empty then hide Address).
If there is no ipv6-prefix, then just display type as normal, and Display Address, even if Address is empty.

The final result looks like below, which makes the status page look more proper. This is all info that is assigned by the ISP. And since prefix delegated is assigned by the ISP, it should be displayed here, under IP or under a new heading. Knowing the size of the prefix delegated by the ISP is also useful information when dealing with IPv6 problems. For example I see my ISP gave me a /56, and my assigned Prefix to my LAN side is a /60 (Under network).
s27.postimg.org/44xj6rov7/Capture.png

EDIT: without the changes above, if you use IPv6 w/ Prefix Delgation, you get the same picture, but with no TYPE listed, and an "Address" field which returns empty space " ".

EDIT2: To see the TYPE and PREFIX, you can call this command. As you can see in a PD setup, this will give the below code, showing ipv6-address & ipv6-prefix-assignment are empty, and that you should grab the info from ipv6-prefix for the Prefix which was given to u by ur ISP (and display this on status).

ubus call network.interface.wan6 status
        "proto": "dhcpv6",
        "ipv6-address": [

        ],
        "ipv6-prefix": [
                {
                        "address": "2001:xxxx:xxxx:d000::",
                        "mask": 56,
                        "preferred": 119174,
                        "valid": 291974,
                        "class": "wan6",
                        "assigned": {
                                "lan": {
                                        "address": "2001:xxxx:xxxx:d000::",
                                        "mask": 60
                                }
                        }
                }
        ],
        "ipv6-prefix-assignment": [

        ],

(Last edited by codster on 20 Jan 2017, 06:03)

I also agree added ipv6 info would be nice.

(Last edited by cybrnook2002 on 21 Jan 2017, 04:25)

The discussion might have continued from here.