/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 <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2020-10-07 11:46:46 +00:00
parent 391540d9d8
commit b67f02d512
13 changed files with 20 additions and 66 deletions

View File

@@ -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

View File

@@ -0,0 +1 @@
../../../common/setup

View File

@@ -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

View File

@@ -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
;;

View File

@@ -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

View File

@@ -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
;;

View File

@@ -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
;;

View File

@@ -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
;;

View File

@@ -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

View File

@@ -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

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -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);
}
}