All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Add vlan information to net_ls_addr output
@ 2022-03-05  3:46 Chad Kimes
  2022-03-05  3:46 ` [PATCH 2/2] Add net_set_vlan command Chad Kimes
  2022-03-17 22:52 ` [PATCH 1/2] Add vlan information to net_ls_addr output Daniel Kiper
  0 siblings, 2 replies; 6+ messages in thread
From: Chad Kimes @ 2022-03-05  3:46 UTC (permalink / raw)
  To: grub-devel; +Cc: Chad Kimes

Example output:
  grub> net_ls_addr
  efinet1 00:11:22:33:44:55 192.168.0.100 vlan100

Signed-off-by: Chad Kimes <chkimes@github.com>
---
 grub-core/net/net.c | 18 +++++++++++++++++-
 include/grub/net.h  |  8 ++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/grub-core/net/net.c b/grub-core/net/net.c
index 4d3eb5c1a..33e35d5b5 100644
--- a/grub-core/net/net.c
+++ b/grub-core/net/net.c
@@ -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,11 @@ 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;
 }
diff --git a/include/grub/net.h b/include/grub/net.h
index 7ae4b6bd8..7fccad8ec 100644
--- a/include/grub/net.h
+++ b/include/grub/net.h
@@ -512,12 +512,20 @@ 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);
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH 0/2] Add command-line management of VLAN config
@ 2022-03-21 21:29 Chad Kimes
  2022-03-21 21:29 ` [PATCH 1/2] Add vlan information to net_ls_addr output Chad Kimes
  0 siblings, 1 reply; 6+ messages in thread
From: Chad Kimes @ 2022-03-21 21:29 UTC (permalink / raw)
  To: grub-devel; +Cc: Chad Kimes

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(-)

-- 
2.25.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-03-21 21:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-05  3:46 [PATCH 1/2] Add vlan information to net_ls_addr output Chad Kimes
2022-03-05  3:46 ` [PATCH 2/2] Add net_set_vlan command Chad Kimes
2022-03-17 23:03   ` Daniel Kiper
2022-03-21 18:23     ` Chad Kimes
2022-03-17 22:52 ` [PATCH 1/2] Add vlan information to net_ls_addr output Daniel Kiper
  -- strict thread matches above, loose matches on Subject: below --
2022-03-21 21:29 [PATCH 0/2] Add command-line management of VLAN config Chad Kimes
2022-03-21 21:29 ` [PATCH 1/2] Add vlan information to net_ls_addr output Chad Kimes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.