[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 5/5] hotplug/linux: Add IPv6 support to vif-route
On Tue, 2014-05-20 at 10:06 +0200, Sylvain Munaut wrote: > >> +## > >> +# ip6_of interface > >> +# > >> +# Print the first IPv6 address currently in use at the given interface, > >> or nothing if > >> +# the interface is not up. > >> +# > >> +ip6_of() > >> +{ > >> + ip -6 addr show primary dev "$1" | perl -wane '/scope global/ && > >> /inet6 (([0-9a-f]+:*)+)/ && print $1;' > > > > Hrm, Perl again. Can this be done with awk? Looks tricky though. > > > > Changed to : > > ip -6 -o addr show primary dev "$1" scope global | awk '$3 == "inet6" > {split($4,i,"/"); print i[1]; exit}' > > which is now very similar to the ip_of() function. thanks. In theory I think this could be combined into a single helper which took $2 == '4' or '6' and "ip -$2 | ... inet${2%4}.." (then ip_of and ip6_of become invocations of that) But perhaps the ${2%4} bit is overly cryptic? Ian. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |