From b67f02d512335f235710934bafe15db87067316d Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 7 Oct 2020 11:46:46 +0000 Subject: [PATCH] /var/ipfire/ethernet/settings: Drop BROADCAST variable This variable is no longer being used and was only used to assign IP addresses to the individual interfaces. However, the kernel knows best which IP address to select as broadcast address for each network. Therefore we depend on the kernel which allows us to support RFC3021. Fixes: #12486 - no /31 transfer net available on red Signed-off-by: Michael Tremer --- config/rootfiles/core/152/filelists/files | 8 ++++++++ config/rootfiles/core/152/filelists/setup | 1 + lfs/wio | 2 +- src/initscripts/helper/aws-setup | 5 ----- src/initscripts/helper/azure-setup | 7 +------ src/initscripts/helper/exoscale-setup | 4 ---- src/initscripts/helper/gcp-setup | 4 ---- src/initscripts/helper/oci-setup | 5 ----- src/initscripts/networking/any | 11 +---------- src/initscripts/networking/red | 9 +-------- src/misc-progs/setaliases.c | 13 +++---------- src/setup/netstuff.c | 13 +------------ src/wio/wio.cgi | 4 +++- 13 files changed, 20 insertions(+), 66 deletions(-) create mode 120000 config/rootfiles/core/152/filelists/setup diff --git a/config/rootfiles/core/152/filelists/files b/config/rootfiles/core/152/filelists/files index 0894d828f1..b80348eb00 100644 --- a/config/rootfiles/core/152/filelists/files +++ b/config/rootfiles/core/152/filelists/files @@ -1,3 +1,11 @@ etc/system-release etc/issue +etc/rc.d/helpers/aws-setup +etc/rc.d/helpers/azure-setup +etc/rc.d/helpers/exoscale-setup +etc/rc.d/helpers/gcp-setup +etc/rc.d/helpers/oci-setup +etc/rc.d/init.d/networking/any +etc/rc.d/init.d/networking/red srv/web/ipfire/cgi-bin/credits.cgi +usr/local/bin/setaliases diff --git a/config/rootfiles/core/152/filelists/setup b/config/rootfiles/core/152/filelists/setup new file mode 120000 index 0000000000..209374bbcf --- /dev/null +++ b/config/rootfiles/core/152/filelists/setup @@ -0,0 +1 @@ +../../../common/setup \ No newline at end of file diff --git a/lfs/wio b/lfs/wio index e0dd53689f..b4222f1b58 100644 --- a/lfs/wio +++ b/lfs/wio @@ -15,7 +15,7 @@ THISAPP = wio-$(VER) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = wio -PAK_VER = 10 +PAK_VER = 11 ############################################################################### # Top-level Rules diff --git a/src/initscripts/helper/aws-setup b/src/initscripts/helper/aws-setup index 9b67019d62..4867540bd3 100644 --- a/src/initscripts/helper/aws-setup +++ b/src/initscripts/helper/aws-setup @@ -146,12 +146,10 @@ import_aws_configuration() { local prefix="${subnet#*/}" local netmask="$(prefix2netmask "${prefix}")" - local netmask_num="$(to_integer "${netmask}")" # Calculate the network and broadcast addresses local netaddress="${subnet%/*}" local netaddress_num="$(to_integer "${netaddress}")" - local broadcast="$(to_address $(( ipv4_address_num | (0xffffffff ^ netmask_num) )))" case "${device_number}" in # RED @@ -169,7 +167,6 @@ import_aws_configuration() { echo "RED_ADDRESS=${ipv4_address}" echo "RED_NETMASK=${netmask}" echo "RED_NETADDRESS=${netaddress}" - echo "RED_BROADCAST=${broadcast}" echo "RED_MTU=1500" echo "DEFAULT_GATEWAY=${gateway}" ) >> /var/ipfire/ethernet/settings @@ -191,7 +188,6 @@ import_aws_configuration() { echo "GREEN_ADDRESS=${ipv4_address}" echo "GREEN_NETMASK=${netmask}" echo "GREEN_NETADDRESS=${netaddress}" - echo "GREEN_BROADCAST=${broadcast}" echo "GREEN_MTU=${DEFAULT_MTU}" ) >> /var/ipfire/ethernet/settings ;; @@ -208,7 +204,6 @@ import_aws_configuration() { echo "ORANGE_ADDRESS=${ipv4_address}" echo "ORANGE_NETMASK=${netmask}" echo "ORANGE_NETADDRESS=${netaddress}" - echo "ORANGE_BROADCAST=${broadcast}" echo "ORANGE_MTU=${DEFAULT_MTU}" ) >> /var/ipfire/ethernet/settings ;; diff --git a/src/initscripts/helper/azure-setup b/src/initscripts/helper/azure-setup index 291b8e0a4d..5157712fcd 100644 --- a/src/initscripts/helper/azure-setup +++ b/src/initscripts/helper/azure-setup @@ -160,12 +160,10 @@ import_azure_configuration() { local ipv4_address_num="$(to_integer "${ipv4_address}")" local prefix="$(get "network/interface/${device_number}/ipv4/subnet/0/prefix")" local netmask="$(prefix2netmask "${prefix}")" - local netmask_num="$(to_integer "${netmask}")" - # Calculate the network and broadcast addresses + # Get the network address local netaddress="$(get "network/interface/${device_number}/ipv4/subnet/0/address")" local netaddress_num="$(to_integer "${netaddress}")" - local broadcast="$(to_address $(( ipv4_address_num | (0xffffffff ^ netmask_num) )))" case "${device_number}" in # RED @@ -183,7 +181,6 @@ import_azure_configuration() { echo "RED_ADDRESS=${ipv4_address}" echo "RED_NETMASK=${netmask}" echo "RED_NETADDRESS=${netaddress}" - echo "RED_BROADCAST=${broadcast}" echo "DEFAULT_GATEWAY=${gateway}" ) >> /var/ipfire/ethernet/settings @@ -213,7 +210,6 @@ import_azure_configuration() { echo "GREEN_ADDRESS=${ipv4_address}" echo "GREEN_NETMASK=${netmask}" echo "GREEN_NETADDRESS=${netaddress}" - echo "GREEN_BROADCAST=${broadcast}" ) >> /var/ipfire/ethernet/settings ;; @@ -229,7 +225,6 @@ import_azure_configuration() { echo "ORANGE_ADDRESS=${ipv4_address}" echo "ORANGE_NETMASK=${netmask}" echo "ORANGE_NETADDRESS=${netaddress}" - echo "ORANGE_BROADCAST=${broadcast}" ) >> /var/ipfire/ethernet/settings ;; esac diff --git a/src/initscripts/helper/exoscale-setup b/src/initscripts/helper/exoscale-setup index 24e98d38ba..2ff8a18a24 100644 --- a/src/initscripts/helper/exoscale-setup +++ b/src/initscripts/helper/exoscale-setup @@ -122,7 +122,6 @@ import_exoscale_configuration() { GREEN_ADDRESS="10.0.0.1" GREEN_NETMASK="255.255.255.0" GREEN_NETADDRESS="10.0.0.0" - GREEN_BROADCAST="10.0.0.255" fi ( @@ -132,7 +131,6 @@ import_exoscale_configuration() { echo "GREEN_ADDRESS=${GREEN_ADDRESS}" echo "GREEN_NETMASK=${GREEN_NETMASK}" echo "GREEN_NETADDRESS=${GREEN_NETADDRESS}" - echo "GREEN_BROADCAST=${GREEN_BROADCAST}" echo "GREEN_MTU=${DEFAULT_MTU}" ) >> /var/ipfire/ethernet/settings ;; @@ -146,7 +144,6 @@ import_exoscale_configuration() { ORANGE_ADDRESS="10.0.1.1" ORANGE_NETMASK="255.255.255.0" ORANGE_NETADDRESS="10.0.1.0" - ORANGE_BROADCAST="10.0.1.255" fi ( @@ -156,7 +153,6 @@ import_exoscale_configuration() { echo "ORANGE_ADDRESS=${ORANGE_ADDRESS}" echo "ORANGE_NETMASK=${ORANGE_NETMASK}" echo "ORANGE_NETADDRESS=${ORANGE_NETADDRESS}" - echo "ORANGE_BROADCAST=${ORANGE_BROADCAST}" echo "ORANGE_MTU=${DEFAULT_MTU}" ) >> /var/ipfire/ethernet/settings ;; diff --git a/src/initscripts/helper/gcp-setup b/src/initscripts/helper/gcp-setup index eab09eb2ca..8868750dbc 100644 --- a/src/initscripts/helper/gcp-setup +++ b/src/initscripts/helper/gcp-setup @@ -142,7 +142,6 @@ import_gcp_configuration() { # Calculate the network and broadcast addresses local netaddress="$(to_address $(( ipv4_address_num & netmask_num )))" - local broadcast="$(to_address $(( ipv4_address_num | (0xffffffff ^ netmask_num) )))" case "${device_number}" in # RED @@ -158,7 +157,6 @@ import_gcp_configuration() { echo "RED_ADDRESS=${ipv4_address}" echo "RED_NETMASK=${netmask}" echo "RED_NETADDRESS=${netaddress}" - echo "RED_BROADCAST=${broadcast}" echo "RED_MTU=${DEFAULT_MTU}" echo "DEFAULT_GATEWAY=${gateway}" ) >> /var/ipfire/ethernet/settings @@ -180,7 +178,6 @@ import_gcp_configuration() { echo "GREEN_ADDRESS=${ipv4_address}" echo "GREEN_NETMASK=${netmask}" echo "GREEN_NETADDRESS=${netaddress}" - echo "GREEN_BROADCAST=${broadcast}" echo "GREEN_MTU=${DEFAULT_MTU}" ) >> /var/ipfire/ethernet/settings ;; @@ -197,7 +194,6 @@ import_gcp_configuration() { echo "ORANGE_ADDRESS=${ipv4_address}" echo "ORANGE_NETMASK=${netmask}" echo "ORANGE_NETADDRESS=${netaddress}" - echo "ORANGE_BROADCAST=${broadcast}" echo "ORANGE_MTU=${DEFAULT_MTU}" ) >> /var/ipfire/ethernet/settings ;; diff --git a/src/initscripts/helper/oci-setup b/src/initscripts/helper/oci-setup index aca09e6739..0763a96e7c 100644 --- a/src/initscripts/helper/oci-setup +++ b/src/initscripts/helper/oci-setup @@ -147,11 +147,9 @@ import_oci_configuration() { local prefix="${subnet#*/}" local netmask="$(prefix2netmask "${prefix}")" - local netmask_num="$(to_integer "${netmask}")" # Calculate the network and broadcast addresses local netaddress="${subnet%/*}" - local broadcast="$(to_address $(( ipv4_address_num | (0xffffffff ^ netmask_num) )))" local index="$(oci_get_interface_param "${id}" "nicIndex")" @@ -174,7 +172,6 @@ import_oci_configuration() { echo "RED_ADDRESS=${ipv4_address}" echo "RED_NETMASK=${netmask}" echo "RED_NETADDRESS=${netaddress}" - echo "RED_BROADCAST=${broadcast}" echo "RED_MTU=1500" echo "DEFAULT_GATEWAY=${gateway}" ) >> /var/ipfire/ethernet/settings @@ -196,7 +193,6 @@ import_oci_configuration() { echo "GREEN_ADDRESS=${ipv4_address}" echo "GREEN_NETMASK=${netmask}" echo "GREEN_NETADDRESS=${netaddress}" - echo "GREEN_BROADCAST=${broadcast}" echo "GREEN_MTU=${DEFAULT_MTU}" ) >> /var/ipfire/ethernet/settings ;; @@ -213,7 +209,6 @@ import_oci_configuration() { echo "ORANGE_ADDRESS=${ipv4_address}" echo "ORANGE_NETMASK=${netmask}" echo "ORANGE_NETADDRESS=${netaddress}" - echo "ORANGE_BROADCAST=${broadcast}" echo "ORANGE_MTU=${DEFAULT_MTU}" ) >> /var/ipfire/ethernet/settings ;; diff --git a/src/initscripts/networking/any b/src/initscripts/networking/any index 0cf107f484..7ca1ab2c3d 100644 --- a/src/initscripts/networking/any +++ b/src/initscripts/networking/any @@ -22,7 +22,6 @@ eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) if [ "$(basename $0)" == "green" ]; then DEVICE="${GREEN_DEV}" ADDRESS="${GREEN_ADDRESS}" - BROADCAST="${GREEN_BROADCAST}" NETADDRESS="${GREEN_NETADDRESS}" NETMASK="${GREEN_NETMASK}" DEVICE="${GREEN_DEV}" @@ -30,7 +29,6 @@ if [ "$(basename $0)" == "green" ]; then elif [ "$(basename $0)" == "blue" ]; then DEVICE="${BLUE_DEV}" ADDRESS="${BLUE_ADDRESS}" - BROADCAST="${BLUE_BROADCAST}" NETADDRESS="${BLUE_NETADDRESS}" NETMASK="${BLUE_NETMASK}" DEVICE="${BLUE_DEV}" @@ -38,22 +36,15 @@ elif [ "$(basename $0)" == "blue" ]; then elif [ "$(basename $0)" == "orange" ]; then DEVICE="${ORANGE_DEV}" ADDRESS="${ORANGE_ADDRESS}" - BROADCAST="${ORANGE_BROADCAST}" NETADDRESS="${ORANGE_NETADDRESS}" NETMASK="${ORANGE_NETMASK}" DEVICE="${ORANGE_DEV}" MTU="${ORANGE_MTU}" fi -if [ -z "${BROADCAST}" ]; then - boot_mesg "BROADCAST variable missing from input, cannot continue." ${FAILURE} - echo_failure - exit 1 -fi - if [ -n "${ADDRESS}" -a -n "${NETMASK}" ]; then PREFIX=`whatmask ${NETMASK} | grep -e ^CIDR | awk -F': ' '{ print $2 }' | cut -c 2-` - args="${args} ${ADDRESS}/${PREFIX} broadcast ${BROADCAST}" + args="${args} ${ADDRESS}/${PREFIX}" else boot_mesg "ADDRESS and/or NETMASK variable missing from input, cannot continue." ${FAILURE} echo_failure diff --git a/src/initscripts/networking/red b/src/initscripts/networking/red index 44e0daa68e..ca0a8ae58b 100644 --- a/src/initscripts/networking/red +++ b/src/initscripts/networking/red @@ -51,13 +51,11 @@ fi if [ "${TYPE}" == "STATIC" ]; then if [ "${DEVICE}" != "${GREEN_DEV}" ]; then ADDRESS="${RED_ADDRESS}" - BROADCAST="${RED_BROADCAST}" NETADDRESS="${RED_NETADDRESS}" NETMASK="${RED_NETMASK}" MTU="${RED_MTU}" else ADDRESS="${GREEN_ADDRESS}" - BROADCAST="${GREEN_BROADCAST}" NETADDRESS="${GREEN_NETADDRESS}" NETMASK="${GREEN_NETMASK}" MTU="${GREEN_MTU}" @@ -66,14 +64,9 @@ if [ "${TYPE}" == "STATIC" ]; then # DNS1 # DNS2 - if [ -z "${BROADCAST}" ]; then - boot_mesg "BROADCAST variable missing, cannot continue." ${FAILURE} - echo_failure - exit 1 - fi if [ -n "${ADDRESS}" -a -n "${NETMASK}" ]; then PREFIX=`whatmask ${NETMASK} | grep -e ^CIDR | awk -F': ' '{ print $2 }' | cut -c 2-` - args="${args} ${ADDRESS}/${PREFIX} broadcast ${BROADCAST}" + args="${args} ${ADDRESS}/${PREFIX}" else boot_mesg "ADDRESS and/or NETMASK variable missing from input, cannot continue." ${FAILURE} echo_failure diff --git a/src/misc-progs/setaliases.c b/src/misc-progs/setaliases.c index 93af1cb0a4..10ffd438d9 100644 --- a/src/misc-progs/setaliases.c +++ b/src/misc-progs/setaliases.c @@ -39,7 +39,6 @@ int main(void) char s[STRING_SIZE]; char command[STRING_SIZE]; char red_netmask[STRING_SIZE]; - char red_broadcast[STRING_SIZE]; char red_dev[STRING_SIZE]; char default_gateway[STRING_SIZE]; char *aliasip; @@ -94,7 +93,7 @@ int main(void) exit(0); /* Get the RED interface details */ - if((!findkey(kv, "RED_NETMASK", red_netmask)) || (!findkey(kv, "RED_BROADCAST", red_broadcast)) || + if((!findkey(kv, "RED_NETMASK", red_netmask)) || (!findkey(kv, "RED_DEV", red_dev)) || (!findkey(kv, "DEFAULT_GATEWAY", default_gateway))) { fprintf(stderr, "Cannot read RED settings\n"); @@ -113,12 +112,6 @@ int main(void) exit(1); } - if (!VALID_IP(red_broadcast)) - { - fprintf(stderr, "Bad red_broadcast : %s\n", red_broadcast); - exit(1); - } - if (!VALID_IP(default_gateway)) { fprintf(stderr, "Bad default_gateway : %s\n", default_gateway); @@ -184,8 +177,8 @@ int main(void) memset(command, 0, STRING_SIZE); snprintf(command, STRING_SIZE-1, - "/sbin/ifconfig %s:%d %s netmask %s broadcast %s up", - red_dev, alias, aliasip, red_netmask, red_broadcast); + "/sbin/ifconfig %s:%d %s netmask %s up", + red_dev, alias, aliasip, red_netmask); safe_system(command); memset(command, 0, STRING_SIZE); snprintf(command, STRING_SIZE-1, diff --git a/src/setup/netstuff.c b/src/setup/netstuff.c index 66592bb94e..91604de14a 100644 --- a/src/setup/netstuff.c +++ b/src/setup/netstuff.c @@ -265,28 +265,23 @@ int gettype(char *type) return 0; } -/* 0.9.9: calculates broadcast too. */ int setnetaddress(struct keyvalue *kv, char *colour) { char addressfield[STRING_SIZE]; char netaddressfield[STRING_SIZE]; char netmaskfield[STRING_SIZE]; - char broadcastfield[STRING_SIZE]; char address[STRING_SIZE]; char netmask[STRING_SIZE]; unsigned long int intaddress; unsigned long int intnetaddress; unsigned long int intnetmask; - unsigned long int intbroadcast; struct in_addr temp; char *netaddress; - char *broadcast; - + /* Build some key strings. */ sprintf(addressfield, "%s_ADDRESS", colour); sprintf(netaddressfield, "%s_NETADDRESS", colour); sprintf(netmaskfield, "%s_NETMASK", colour); - sprintf(broadcastfield, "%s_BROADCAST", colour); strcpy(address, ""); findkey(kv, addressfield, address); strcpy(netmask, ""); findkey(kv, netmaskfield, netmask); @@ -301,12 +296,6 @@ int setnetaddress(struct keyvalue *kv, char *colour) replacekeyvalue(kv, netaddressfield, netaddress); - intbroadcast = intnetaddress | ~intnetmask; - temp.s_addr = intbroadcast; - broadcast = inet_ntoa(temp); - - replacekeyvalue(kv, broadcastfield, broadcast); - return 1; } diff --git a/src/wio/wio.cgi b/src/wio/wio.cgi index a5d3d149e5..d07332e5e5 100644 --- a/src/wio/wio.cgi +++ b/src/wio/wio.cgi @@ -179,7 +179,9 @@ if ( -e $wiofile ) { goto WIOSCAN; } foreach (@devs_color) { if ( $netsettings{"${_}_DEV"} ne '' ) { $wiosettings{"${_}_IPLOW"} = &Network::find_next_ip_address($netsettings{"${_}_NETADDRESS"}, 1); - $wiosettings{"${_}_IPHIGH"} = &Network::find_next_ip_address($netsettings{"${_}_BROADCAST"}, -1); + + my $broadcast = &Network::get_broadcast($netsettings{"${_}_NETADDRESS"} . "/" . $netsettings{"${_}_NETMASK"}); + $wiosettings{"${_}_IPHIGH"} = &Network::find_next_ip_address($broadcast, -1); } } -- 2.39.2