Add command-line management of VLAN config
cover Add command-line management of VLAN config
These patches provide functionality to configure 802.1Q VLAN identifiers on existing network interfaces using the GRUB command line.
The first patch simply updates the output of net_ls_addr to include information about interface VLAN configuration.
The second patch introduces a new command net_set_vlan that allows configuration of a target network interface, for situations where either the user wants to manually configure a VLAN or where the configuration is not properly being populated in the boot process.
Chad Kimes (2):
Add vlan information to net_ls_addr output
Add net_set_vlan command
docs/grub.texi | 19 ++++++++++++++ grub-core/net/net.c | 61 +++++++++++++++++++++++++++++++++++++++++++-- include/grub/net.h | 6 +++++ 3 files changed, 84 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 Add vlan information to net_ls_addr output
Example output:
grub> net_ls_addr
efinet1 00:11:22:33:44:55 192.0.2.100 vlan100
--- grub-core/net/net.c | 19 ++++++++++++++++++- include/grub/net.h | 6 ++++++ 2 files changed, 24 insertions(+), 1 deletion(-)
grub-core/net/net.c +18 -1
@@ -781,6 +781,20 @@ grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str)grub_printf (_ ("Unsupported hw address type %d\n" ), addr->type); } +void +grub_net_vlan_to_str (grub_uint16_t vlantag,char *str) +{ + str[0 ] =0 ; + +/* 12 bits are used to identify the vlan in 802.1Q */ + vlantag = vlantag &0xFFF ; + +if (vlantag ==0 ) +return ; + +grub_snprintf (str,GRUB_NET_MAX_STR_VLAN_LEN ,"vlan%u" , vlantag); +} +int grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a,const grub_net_link_level_address_t *b)
@@ -1250,9 +1264,12 @@ grub_cmd_listaddrs (struct grub_command *cmd __attribute__ ((unused)), {char bufh[GRUB_NET_MAX_STR_HWADDR_LEN ];char bufn[GRUB_NET_MAX_STR_ADDR_LEN ]; +char bufv[GRUB_NET_MAX_STR_VLAN_LEN ]; +grub_net_hwaddr_to_str (&inf->hwaddress, bufh);grub_net_addr_to_str (&inf->address, bufn); -grub_printf ("%s %s %s\n" , inf->name, bufh, bufn); +grub_net_vlan_to_str (inf->vlantag, bufv); +grub_printf ("%s %s %s %s\n" , inf->name, bufh, bufn, bufv); }return GRUB_ERR_NONE ; }
include/grub/net.h +6 -0
@@ -512,12 +512,18 @@ grub_net_addr_cmp (const grub_net_network_level_address_t *a,#define GRUB_NET_MAX_STR_HWADDR_LEN (sizeof ("XX:XX:XX:XX:XX:XX")) +/* Max VLAN id = 4094 */ +#define GRUB_NET_MAX_STR_VLAN_LEN (sizeof ("vlanXXXX")) +void grub_net_addr_to_str (const grub_net_network_level_address_t *target,char *buf);void grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr,char *str); +void +grub_net_vlan_to_str (grub_uint16_t vlantag,char *str); +grub_err_t grub_env_set_net_property (const char *intername,const char *suffix,const char *value,grub_size_t len);
Signature · 1 line
2.25.1
PATCH 2/2 Add net_set_vlan command
In reply to Chad KimesPreviously there was no way to set the 802.1Q VLAN identifier, despite support for vlantag in the net module. The only location vlantag was being populated was from PXE boot and only for Open Firmware hardware. This commit allows users to manually configure VLAN information for any interface.
Example usage:
grub> net_ls_addr
efinet1 00:11:22:33:44:55 192.0.2.100
grub> net_set_vlan efinet1 100
grub> net_ls_addr
efinet1 00:11:22:33:44:55 192.0.2.100 vlan100
grub> net_set_vlan efinet1 0
efinet1 00:11:22:33:44:55 192.0.2.100
--- docs/grub.texi | 19 +++++++++++++++++++ grub-core/net/net.c | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-)
docs/grub.texi +19 -0
@@ -5554,6 +5554,7 @@ This command is only available on AArch64 systems. * net_ls_dns:: List DNS servers * net_ls_routes:: List routing entries * net_nslookup:: Perform a DNS lookup +* net_set_vlan:: Set vlan id on an interface @end menu
@@ -5730,6 +5731,24 @@ is given, use default list of servers. @end deffn +@node net_set_vlan +@subsection net_set_vlan + +@deffn Command net_set_vlan @var{interface} @var{vlanid} +Set the 802.1Q VLAN identifier on @var{interface} to @var{vlanid}. For example, to set the VLAN identifier on interface @samp{efinet1} to @samp{100}: + +@example +net_set_vlan efinet1 100 +@end example + +The VLAN identifier can be removed by setting it to @samp{0}: + +@example +net_set_vlan efinet1 0 +@end example +@end deffn + + @node Internationalisation @chapter Internationalisation
grub-core/net/net.c +41 -1
60 lines not on this page · raw message
Signature · 1 line
2.25.1
Quoted 6 lines · Chad Kimes via Grub-devel
These patches provide functionality to configure 802.1Q VLAN identifiers on existing network interfaces using the GRUB command line.
The first patch simply updates the output of
net_ls_addrto include information about interface VLAN configuration.
Quoted 8 lines
The second patch introduces a new command
net_set_vlanthat allows configuration of a target network interface, for situations where either the user wants to manually configure a VLAN or where the configuration is not properly being populated in the boot process.Chad Kimes (2):
Add vlan information tonet_ls_addroutput
Addnet_set_vlancommand
For both patches Reviewed-by: Daniel Kiper <[email protected]>
Thank you for doing this work!
Daniel