From patchwork Sat Sep 22 21:24:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 973624 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kWx8jBEo"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42Hk5W2WZ2z9s8T for ; Sun, 23 Sep 2018 07:25:19 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728315AbeIWDUM (ORCPT ); Sat, 22 Sep 2018 23:20:12 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33450 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728020AbeIWDUL (ORCPT ); Sat, 22 Sep 2018 23:20:11 -0400 Received: by mail-wr1-f65.google.com with SMTP id n11-v6so4820923wro.0 for ; Sat, 22 Sep 2018 14:25:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8qQJrqJZVkxWMGnr5YltZ1LSH9YPEMrIWgQWAX9Hp1M=; b=kWx8jBEoCeT5R1k/lEjhK7EBDWE3aKmfiZd315mbRq52ZoUKM+tK0LDnv7nhsturqI N7XKNFl4uq1gEVl7VN7UjDuyM7xU6kO6EOidps0jGyhZJ2CEtMICjw70G6ILWQD/vRrj 02NQQmzgJ3Rfem0wd+wmL+nSw2CSnsdsfef/ppZ7Tj2gtniSXPqZCFQpFMlwujugEYHd KyvTdyl6U+nMMm5WymxRuigM64vNlV+o8Qsyt0p4JzlddcuKSYJFufrLuDriLc652lyY TLXKKeVOvnlzfvWKQiCmZwrvF/9FY0N8+7MEcHk2bIgyMQIAYbbCJlZ0Wp0shDIqlQdt RAmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8qQJrqJZVkxWMGnr5YltZ1LSH9YPEMrIWgQWAX9Hp1M=; b=JdQlcutcDtcYs1Ysa7itehL+n2hE3NfUDJb4ZyYdyw9CvRqUqGWgwbKwL7sZ3Xhv9i 1voS4X7WSfRP3FrJFGtUHsXeVR1S71VIAFbejxZrlTp8df92Nvmb26zyhH02avMtY4lQ ckRdYrEVS0dVzXnONvTwpZSFPw30IIUWf9ahXB7Ju8pZiSdHKk4qgSfcNxVlwwMsRoZt cOm3qtrKRK3Q9hCBWf7pOlewWk2MpwssZfDDePYiqiJC9fpLOdjfh7w1AGD4lpvH/pM1 8vevLUYIstrdqVFy4IU2X792Iy+M4GlTsWwM4R72VdSA7A4hCNKjKLJlA1ODGcjY7Jzs v9pw== X-Gm-Message-State: ABuFfogcaFhP0SwsoFr6To95LAOZXpLQx5073QD9lPXjMcKz60csc77X cDfIluFANi+fuirEj7H+pducEhTf X-Google-Smtp-Source: ACcGV61rH7SpwTNoz/WMkeC26JX/KfqCN3bG7SEbM9Tl+piqTaJta9kdRpHXlsfT/koqyzLqsVJSBw== X-Received: by 2002:adf:9142:: with SMTP id j60-v6mr3139617wrj.180.1537651508970; Sat, 22 Sep 2018 14:25:08 -0700 (PDT) Received: from localhost.localdomain ([85.119.94.113]) by smtp.gmail.com with ESMTPSA id 75-v6sm16110032wml.21.2018.09.22.14.25.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Sep 2018 14:25:08 -0700 (PDT) From: Petr Vorel To: netdev@vger.kernel.org Cc: Petr Vorel , Stephen Hemminger Subject: [PATCH iproute2 6/7] examples: Remove dhcp-client-script Date: Sat, 22 Sep 2018 23:24:50 +0200 Message-Id: <20180922212451.327-7-petr.vorel@gmail.com> X-Mailer: git-send-email 2.19.0.rc2 In-Reply-To: <20180922212451.327-1-petr.vorel@gmail.com> References: <20180922212451.327-1-petr.vorel@gmail.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This script is obsolete. Signed-off-by: Petr Vorel --- examples/dhcp-client-script | 446 ------------------------------------ 1 file changed, 446 deletions(-) delete mode 100644 examples/dhcp-client-script diff --git a/examples/dhcp-client-script b/examples/dhcp-client-script deleted file mode 100644 index f39bc109..00000000 --- a/examples/dhcp-client-script +++ /dev/null @@ -1,446 +0,0 @@ -#!/bin/bash -# -# dhclient-script for Linux. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version -# 2 of the License, or (at your option) any later version. -# -# Authors: Alexey Kuznetsov, -# -# Probably, I did not understand, what this funny feature as "alias" -# means exactly. For now I suppose, that it is a static address, which -# we should install and preserve. -# - -exec >> /var/log/DHS.log 2>&1 - -echo dhc-script $* reason=$reason -set | grep "^\(old_\|new_\|check_\)" - -LOG () { - echo LOG $* ; -} - -# convert 8bit mask to length -# arg: $1 = mask -# -Mask8ToLen() { - local l=0; - - while [ $l -le 7 ]; do - if [ $[ ( 1 << $l ) + $1 ] -eq 256 ]; then - return $[ 8 - $l ] - fi - l=$[ $l + 1 ] - done - return 0; -} - -# convert inet dotted quad mask to length -# arg: $1 = dotquad mask -# -MaskToLen() { - local masklen=0 - local mask8=$1 - - case $1 in - 0.0.0.0) - return 0; - ;; - 255.*.0.0) - masklen=8 - mask8=${mask8#255.} - mask8=${mask8%.0.0} - ;; - 255.255.*.0) - masklen=16 - mask8=${mask8#255.255.} - mask8=${mask8%.0} - ;; - 255.255.255.*) - masklen=24 - mask8=${mask8#255.255.255.} - ;; - *) - return 255 - ;; - esac - Mask8ToLen $mask8 - return $[ $? + $masklen ] -} - -# calculate ABC "natural" mask -# arg: $1 = dotquad address -# -ABCMask () { - local class; - - class=${1%%.*} - - if [ "$1" = "255.255.255.255" ]; then - echo $1 - elif [ "$1" = "0.0.0.0" ]; then - echo $1 - elif [ $class -ge 224 ]; then - echo 240.0.0.0 - elif [ $class -ge 192 ]; then - echo 255.255.255.0 - elif [ $class -ge 128 ]; then - echo 255.255.0.0 - else - echo 255.0.0.0 - fi -} - -# calculate ABC "natural" mask length -# arg: $1 = dotquad address -# -ABCMaskLen () { - local class; - - class=${1%%.*} - - if [ "$1" = "255.255.255.255" ]; then - return 32 - elif [ "$1" = "0.0.0.0" ]; then - return 0 - elif [ $class -ge 224 ]; then - return 4; - elif [ $class -ge 192 ]; then - return 24; - elif [ $class -ge 128 ]; then - return 16; - else - return 8; - fi -} - -# Delete IP address -# args: $1 = interface -# $2 = address -# $3 = mask -# $4 = broadcast -# $5 = label -# -DelINETAddr () { - local masklen=32 - local addrid=$1 - - LOG DelINETAddr $* - - if [ "$5" ]; then - addrid=$addrid:$5 - fi - LOG ifconfig $addrid down - ifconfig $addrid down -} - -# Add IP address -# args: $1 = interface -# $2 = address -# $3 = mask -# $4 = broadcast -# $5 = label -# -AddINETAddr () { - local mask_arg - local brd_arg - local addrid=$1 - - LOG AddINETAddr $* - - if [ "$5" ]; then - addrid=$addrid:$5 - fi - if [ "$3" ]; then - mask_arg="netmask $3" - fi - if [ "$4" ]; then - brd_arg="broadcast $4" - fi - - LOG ifconfig $addrid $2 $mask_arg $brd_arg up - ifconfig $addrid $2 $mask_arg $brd_arg up -} - -# Add default routes -# args: $1 = routers list -# -AddDefaultRoutes() { - local router - - if [ "$1" ]; then - LOG AddDefaultRoutes $* - for router in $1; do - LOG route add default gw $router - route add default gw $router - done ; - fi -} - -# Delete default routes -# args: $1 = routers list -# -DelDefaultRoutes() { - local router - - if [ "$1" ]; then - LOG DelDefaultRoutes $* - - for router in $1; do - LOG route del default gw $router - route del default gw $router - done - fi -} - -# ping a host -# args: $1 = dotquad address of the host -# -PingNode() { - LOG PingNode $* - if ping -q -c 1 -w 2 $1 ; then - return 0; - fi - return 1; -} - -# Check (and add route, if alive) default routers -# args: $1 = routers list -# returns: 0 if at least one router is alive. -# -CheckRouterList() { - local router - local succeed=1 - - LOG CheckRouterList $* - - for router in $1; do - if PingNode $router ; then - succeed=0 - route add default gw $router - fi - done - return $succeed -} - -# Delete/create static routes. -# args: $1 = operation (del/add) -# $2 = routes list in format "dst1 nexthop1 dst2 ..." -# -# BEWARE: this feature of DHCP is obsolete, because does not -# support subnetting. -# -X-StaticRouteList() { - local op=$1 - local lst="$2" - local masklen - - LOG X-StaticRouteList $* - - if [ "$lst" ]; then - set $lst - while [ $# -gt 1 ]; do - route $op -net $1 netmask `ABCMask "$1"` gw $2 - shift; shift; - done - fi -} - -# Create static routes. -# arg: $1 = routes list in format "dst1 nexthop1 dst2 ..." -# -AddStaticRouteList() { - LOG AddStaticRouteList $* - X-StaticRouteList add "$1" -} - -# Delete static routes. -# arg: $1 = routes list in format "dst1 nexthop1 dst2 ..." -# -DelStaticRouteList() { - LOG DelStaticRouteList $* - X-StaticRouteList del "$1" -} - -# Broadcast unsolicited ARP to update neighbours' caches. -# args: $1 = interface -# $2 = address -# -UnsolicitedARP() { - if [ -f /sbin/arping ]; then - /sbin/arping -A -c 1 -I "$1" "$2" & - (sleep 2 ; /sbin/arping -U -c 1 -I "$1" "$2" ) & - fi -} - -# Duplicate address detection. -# args: $1 = interface -# $2 = test address -# returns: 0, if DAD succeeded. -DAD() { - if [ -f /sbin/arping ]; then - /sbin/arping -c 2 -w 3 -D -I "$1" "$2" - return $? - fi - return 0 -} - - -# Setup resolver. -# args: NO -# domain and nameserver list are passed in global variables. -# -# NOTE: we try to be careful and not to break user supplied resolv.conf. -# The script mangles it, only if it has dhcp magic signature. -# -UpdateDNS() { - local nameserver - local idstring="#### Generated by DHCPCD" - - LOG UpdateDNS $* - - if [ "$new_domain_name" = "" -a "$new_domain_name_servers" = "" ]; then - return 0; - fi - - echo $idstring > /etc/resolv.conf.dhcp - if [ "$new_domain_name" ]; then - echo search $new_domain_name >> /etc/resolv.conf.dhcp - fi - echo options ndots:1 >> /etc/resolv.conf.dhcp - - if [ "$new_domain_name_servers" ]; then - for nameserver in $new_domain_name_servers; do - echo nameserver $nameserver >> /etc/resolv.conf.dhcp - done - else - echo nameserver 127.0.0.1 >> /etc/resolv.conf.dhcp - fi - - if [ -f /etc/resolv.conf ]; then - if [ "`head -1 /etc/resolv.conf`" != "$idstring" ]; then - return 0 - fi - if [ "$old_domain_name" = "$new_domain_name" -a - "$new_domain_name_servers" = "$old_domain_name_servers" ]; then - return 0 - fi - fi - mv /etc/resolv.conf.dhcp /etc/resolv.conf -} - -case $reason in -NBI) - exit 1 - ;; - -MEDIUM) - exit 0 - ;; - -PREINIT) - ifconfig $interface:dhcp down - ifconfig $interface:dhcp1 down - if [ -d /proc/sys/net/ipv4/conf/$interface ]; then - ifconfig $interface:dhcp 10.10.10.10 netmask 255.255.255.255 - ifconfig $interface:dhcp down - if [ -d /proc/sys/net/ipv4/conf/$interface ]; then - LOG The interface $interface already configured. - fi - fi - ifconfig $interface:dhcp up - exit 0 - ;; - -ARPSEND) - exit 0 - ;; - -ARPCHECK) - if DAD "$interface" "$check_ip_address" ; then - exit 0 - fi - exit 1 - ;; - -BOUND|RENEW|REBIND|REBOOT) - if [ "$old_ip_address" -a "$alias_ip_address" -a \ - "$alias_ip_address" != "$old_ip_address" ]; then - DelINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1 - fi - if [ "$old_ip_address" -a "$old_ip_address" != "$new_ip_address" ]; then - DelINETAddr "$interface" "$old_ip_address" "$old_subnet_mask" "$old_broadcast_address" dhcp - DelDefaultRoutes "$old_routers" - DelStaticRouteList "$old_static_routes" - fi - if [ "$old_ip_address" = "" -o "$old_ip_address" != "$new_ip_address" -o \ - "$reason" = "BOUND" -o "$reason" = "REBOOT" ]; then - AddINETAddr "$interface" "$new_ip_address" "$new_subnet_mask" "$new_broadcast_address" dhcp - AddStaticRouteList "$new_static_routes" - AddDefaultRoutes "$new_routers" - UnsolicitedARP "$interface" "$new_ip_address" - fi - if [ "$new_ip_address" != "$alias_ip_address" -a "$alias_ip_address" ]; then - AddINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1 - fi - UpdateDNS - exit 0 - ;; - -EXPIRE|FAIL) - if [ "$alias_ip_address" ]; then - DelINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1 - fi - if [ "$old_ip_address" ]; then - DelINETAddr "$interface" "$old_ip_address" "$old_subnet_mask" "$old_broadcast_address" dhcp - DelDefaultRoutes "$old_routers" - DelStaticRouteList "$old_static_routes" - fi - if [ "$alias_ip_address" ]; then - AddINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1 - fi - exit 0 - ;; - -TIMEOUT) - if [ "$alias_ip_address" ]; then - DelINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1 - fi -# Seems, means, that no more old leases found. -# Or does it mean bug in dhcpcd? 8) Fail for now. - if [ "$new_ip_address" = "" ]; then - if [ "$old_ip_address" ]; then - DelINETAddr "$interface" "$old_ip_address" "$old_subnet_mask" "$old_broadcast_address" dhcp - fi - if [ "$alias_ip_address" ]; then - AddINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1 - fi - exit 1 - fi - if DAD "$interface" "$new_ip_address" ; then - AddINETAddr "$interface" "$new_ip_address" "$new_subnet_mask" "$new_broadcast_address" dhcp - UnsolicitedARP "$interface" "$new_ip_address" - if [ "$alias_ip_address" -a "$alias_ip_address" != "$new_ip_address" ]; then - AddINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1 - UnsolicitedARP "$interface" "$alias_ip_address" - fi - if CheckRouterList "$new_routers" ; then - AddStaticRouteList "$new_static_routes" - UpdateDNS - exit 0 - fi - fi - DelINETAddr "$interface" "$new_ip_address" "$new_subnet_mask" "$new_broadcast_address" dhcp - DelDefaultRoutes "$old_routers" - DelStaticRouteList "$old_static_routes" - if [ "$alias_ip_address" ]; then - AddINETAddr "$interface" "$alias_ip_address" "$alias_subnet_mask" "$alias_broadcast_address" dhcp1 - fi - exit 1 - ;; -esac - -exit 0