Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/etc/rc.d handle v6 addresses



details:   https://anonhg.NetBSD.org/src/rev/5d353a14a208
branches:  trunk
changeset: 992084:5d353a14a208
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Aug 13 09:16:06 2018 +0000

description:
handle v6 addresses

diffstat:

 etc/rc.d/ipsec |  18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diffs (49 lines):

diff -r c3861fe381c6 -r 5d353a14a208 etc/rc.d/ipsec
--- a/etc/rc.d/ipsec    Mon Aug 13 08:48:46 2018 +0000
+++ b/etc/rc.d/ipsec    Mon Aug 13 09:16:06 2018 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: ipsec,v 1.14 2016/10/19 21:27:10 christos Exp $
+# $NetBSD: ipsec,v 1.15 2018/08/13 09:16:06 christos Exp $
 #
 
 # PROVIDE: ipsec
@@ -32,7 +32,11 @@
 ipsec_getip() {
        ifconfig $1 | while IFS="${IFS}/" read what address rest; do
                case "$what" in
-               inet)   echo "$address";;
+               inet)   echo "local v4_addr=$address;";;
+               inet6)  case "$address" in
+                       fe80:)  ;;
+                       *)      echo "local v6_addr=$address;";;
+                       esac;;
                esac
        done
 }
@@ -41,18 +45,20 @@
        if [ -z "$1" ]; then
                /sbin/setkey -f /etc/ipsec.conf
        else
-               sed -e "s/@LOCAL_ADDR@/$1/" < /etc/ipsec.conf | \
+               sed     -e "s/@LOCAL_ADDR@/$1/" \
+                       -e "s/@LOCAL_ADDR_V4@/$1/" \
+                       -e "s/@LOCAL_ADDR_V6@/$2/" /etc/ipsec.conf | \
                    /sbin/setkey -f -
        fi
 }
 
 ipsec_configure() {
        while true; do
-               local addr="$(ipsec_getip "$ipsec_flags")"
-               case "$addr" in
+               eval $(ipsec_getip "$ipsec_flags")
+               case "$v4_addr" in
                '')             sleep 1;;
                "0.0.0.0")      sleep 1;;
-               *)              ipsec_load "$addr"; return;;
+               *)              ipsec_load "$v4_addr" "$v6_addr"; return;;
                esac
        done &
 }



Home | Main Index | Thread Index | Old Index