Hi Alan,

Thank you for your comments.

2012/5/31 Alan Robertson <al...@unix.sh>:
> It's straightforward to determine if an IP address is link-local or not -
> for an already configured address.
>
> 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state
> UP qlen 1000
>     link/ether 94:db:c9:3f:7c:20 brd ff:ff:ff:ff:ff:ff
>     inet 10.10.10.30/24 brd 10.10.10.255 scope global eth1
>     inet6 fe80::96db:c9ff:fe3f:7c20/64 scope link
>        valid_lft forever preferred_lft forever
>
> This works uniformly for both ipv4 and ipv6 addresses (quite nice!)

It's an interesting idea, but I don't think we need to care about IPv4
link-local addresses
because users can configure using the same manner as a "regular" IP address.
(and it's used very rarely)

In the case of IPv6 link-local addresses it is almost always a wrong
configuration if nic is missing
(the socket API mandate it) so we want to check it.

>
> However, for addresses which are not yet up (which is unfortunately what
> you're concerned with),  ipv6 link-local addresses take the form
>                   fe80:: -- followed by 64-bits of MAC addresses (48 bit
> MACs are padded out)
>
> http://en.wikipedia.org/wiki/Link-local_address
>
> MAC addresses never begin with 4 bytes of zeros, so the regular expression
> to match this is pretty straightforward.  This isn't a bad approximation
> (but could easily be made better):

Yes, you are right. Matching to 'fe80::' should be pretty easy and good enough.
Why I could not think of such a simple idea :)


>
> islinklocal() {
>       if
>          echo $1 | grep -i '^fe80::[^:]*:[^:]*:[^:]*:[^:]*$' >/dev/null

We should also accept 'fe80::1'.
Anyway I will look into this way.

Thanks,

-- 
Keisuke MORI
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to