[vlan] Use "-" instead of "." as separator in VLAN device names
VLAN device names have the form "netX.Y", e.g. "net0.5" for VLAN 5 on
net0. This use of "." conflicts with the use of "." as the
hierarchical separator in settings block names, with the result that
VLAN device settings cannot be accessed by name.
It would be trivial to treat the VLAN device settings as being a child
of the trunk device settings, but this would cause the VLAN device
settings to be applied to the trunk device: for example, setting
"net0.5/ip" would then apply the IP address to both net0.5 and net0.
Fix by changing the VLAN device name to use "-" instead of ".": the
VLAN device "net0.5" is now "net0-5".
Signed-off-by: Michael Brown <mcb30@ipxe.org>
[settings] Apply settings block name in register_settings()
Pass the settings block name as a parameter to register_settings(),
rather than defining it with settings_init() (and then possibly
changing it by directly manipulating settings->name).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
[cmdline] Match user expectations for &&, ||, goto, and exit
The && and || operators should be left-associative, since that is how
they are treated in most other languages (including C and Unix
shell). For example, in the command:
dhcp net0 && goto dhcp_ok || echo No DHCP on net0
if the "dhcp net0" fails then the "echo" should be executed.
After an "exit" or a successful "goto", further commands on the same
line should never be executed. For example:
goto somewhere && echo This should never be printed
exit 0 && echo This should never be printed
exit 1 && echo This should never be printed
An "exit" should cause the current shell or script to terminate and
return the specified exit status to its caller. For example:
chain test.ipxe && echo Success || echo Failure
[in test.ipxe]
#!ipxe
exit 0
should echo "Success".
Signed-off-by: Michael Brown <mcb30@ipxe.org>
The "shell" command allows a script to enter an interactive shell,
which is potentially useful for troubleshooting.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Some newer versions of gcc (observed with a patched gcc 4.5.1) seem to
treat our offsetof() implementation as not being a compile-time
constant. Fix by using __builtin_offsetof() when available. (As with
the original offsetof() macro, this code is copied from the Linux
kernel's stddef.h.)
Reported-by: Arkadiusz Miskiewicz <arekm@maven.pl>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
[fcoe] Use only the first instance of a FIP descriptor
Almost all FIP packets contain at most one instance of each
descriptor. A VLAN notification may contain multiple VLAN
descriptors. The FCoE specification does not provide any guidance
regarding prioritisation of VLANs, so we may choose to arbitrarily
choose the first listed VLAN.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
VLAN headers are allowed to contain a VLAN tag of zero, indicating
that the header specifies only a priority and that the packet does not
belong to any VLAN. The easiest way to handle this is to treat VLAN 0
as being a normal VLAN.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
The increase in length in Fibre Channel device names causes the
"selected FCF" message to wrap beyond 80 characters. Fix by using
abbreviations where possible.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
[fcoe] Create Fibre Channel port only when we have selected an FCF
Create the Fibre Channel port only when the FCoE port has selected a
Fibre Channel Forwarder to use. This avoids the confusion of having
an FC port created for the network device on which only VLAN discovery
is performed.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Allow the fragment list to be omitted when calling nvo_init().
Omitting the list will cause the whole of the NVS device to be used
for NVO storage.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Expansion of the (admittedly perverse) "aaa}bbb${ccc" will currently
fail because expand_command() does not check that the closing "}"
occurs later than the opening "${".
Fix by ensuring that the most recent opening "${" is used to match
against the first *subsequent* closing "}".
Total cost of this change: -12 bytes, bringing the overall cost of
this feature to -4 bytes.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Expansion of ${${foo}} will currently fail, because the first
opening "${" will be incorrectly matched against the first closing
"}", leading to an attempt to expand the variable "${foo".
Fix by ensuring that the most recent opening "${" is used to match
against the first closing "}".
Total cost: 8 bytes. :)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
[settings] Allow "set" command to take an empty value
Allow "set <variable>" to be used to set the variable to an empty
value, if permitted by the setting type. Note that some settings
backends do not differentiate between an empty value and a
non-existent value, so this may or may not be equivalent to "clear
<variable>".
Signed-off-by: Michael Brown <mcb30@ipxe.org>
[autoboot] Merge "netboot" command into "autoboot"
Allow "autoboot" to accept an optional list of network devices, and
remove the "netboot" command. This saves around 130 bytes.
The "netboot" command has existed for approximately 48 hours, so its
removal should not cause backwards compatibility issues for anyone.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
The "isset" command can be used to determine whether or not a setting
is present. For example:
isset ${net0/ip} || dhcp net0 # If we have no IP address, try DHCP
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Allow script labels to be defined using the syntax
:<labelname>
(nothing else allowed on the line, including whitespace). Labels are
ignored during script execution, but can be used as the target of the
"goto" command. For example:
#!ipxe
goto machine_${net0/ip} || goto machine_default
# Linux kernel boot
:machine_10.0.0.101
:machine_10.0.0.102
set filename http://my.boot.server/vmlinuz
goto done
# Default configuration
:machine_default
set filename pxelinux.0
goto done
# Boot selected configuration
:done
chain ${filename}
Originally-implemented-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Originally-implemented-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
[cmdline] Add trivial logical operators to iPXE command lines
Make the "||" and "&&" operators available within iPXE commands. For
example:
dhcp net0 || set net0/ip 192.168.0.2
would attempt to acquire an IP address via DHCP, falling back to a
static address if DHCP fails.
As a side-effect, comments may now be appended to any line. For
example:
dhcp net0 || set net0/ip 192.168.0.2 # Try DHCP first, then static
Signed-off-by: Michael Brown <mcb30@ipxe.org>
[pxe] Remove startpxe and stoppxe commands from default builds
These commands exist primarily for debugging and are not generally
useful, so save 137 bytes by removing them by default.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Command implementations tend to include a substantial amount of common
boilerplate code revolving around the parsing of command-line options
and arguments. This increases the size cost of each command.
Introduce an option-parsing library that abstracts out the common
operations involved in command implementations. This enables the size
of each individual command to be reduced, and also enhances
consistency between commands.
Total size of the library is 704 bytes, to be amortised across all
command implementations.
Signed-off-by: Michael Brown <mcb30@ipxe.org>