1 diff -urNp grub-2.02-rc1.orig/grub-core/kern/ieee1275/init.c grub-2.02-rc1/grub-core/kern/ieee1275/init.c
2 --- grub-2.02-rc1.orig/grub-core/kern/ieee1275/init.c 2017-02-08 15:06:05.420317447 +0000
3 +++ grub-2.02-rc1/grub-core/kern/ieee1275/init.c 2017-02-08 15:06:17.784317308 +0000
4 @@ -125,6 +125,7 @@ grub_machine_get_bootlocation (char **de
7 dev = grub_ieee1275_get_aliasdevname (bootpath);
8 + grub_ieee1275_parse_net_options (bootpath);
9 canon = grub_ieee1275_canonicalise_devname (dev);
10 ptr = canon + grub_strlen (canon) - 1;
11 while (ptr > canon && (*ptr == ',' || *ptr == ':'))
12 diff -urNp grub-2.02-rc1.orig/grub-core/kern/ieee1275/openfw.c grub-2.02-rc1/grub-core/kern/ieee1275/openfw.c
13 --- grub-2.02-rc1.orig/grub-core/kern/ieee1275/openfw.c 2017-02-08 15:06:05.420317447 +0000
14 +++ grub-2.02-rc1/grub-core/kern/ieee1275/openfw.c 2017-02-08 15:06:17.785317308 +0000
17 #include <grub/ieee1275/ieee1275.h>
19 +#include <grub/env.h>
21 enum grub_ieee1275_parse_type
23 @@ -451,6 +452,35 @@ fail:
28 +grub_ieee1275_parse_net_options (const char *path)
34 + args = grub_ieee1275_get_devargs (path);
36 + /* There is no option. */
41 + comma = grub_strchr (args, ',');
43 + option = grub_strdup (args);
45 + option = grub_strndup (args, (grub_size_t)(comma - args));
48 + if (! grub_strncmp(option, "vtag", 4))
49 + grub_env_set ("vlan-tag", option + grub_strlen("vtag="));
57 grub_ieee1275_get_device_type (const char *path)
59 diff -urNp grub-2.02-rc1.orig/grub-core/net/ethernet.c grub-2.02-rc1/grub-core/net/ethernet.c
60 --- grub-2.02-rc1.orig/grub-core/net/ethernet.c 2017-02-08 15:06:05.433317447 +0000
61 +++ grub-2.02-rc1/grub-core/net/ethernet.c 2017-02-08 15:06:17.785317308 +0000
63 #include <grub/net/arp.h>
64 #include <grub/net/netbuff.h>
66 +#include <grub/env.h>
67 #include <grub/time.h>
68 #include <grub/net/arp.h>
70 @@ -56,10 +57,19 @@ send_ethernet_packet (struct grub_net_ne
74 + grub_uint32_t vlantag = 0;
75 + grub_uint8_t etherhdr_size;
77 - COMPILE_TIME_ASSERT (sizeof (*eth) < GRUB_NET_MAX_LINK_HEADER_SIZE);
78 + etherhdr_size = sizeof (*eth);
79 + COMPILE_TIME_ASSERT (sizeof (*eth) + 4 < GRUB_NET_MAX_LINK_HEADER_SIZE);
81 - err = grub_netbuff_push (nb, sizeof (*eth));
82 + const char *vlantag_text = grub_env_get ("vlan-tag");
83 + if (vlantag_text != 0) {
85 + vlantag = grub_strtoul (vlantag_text, 0, 16);
88 + err = grub_netbuff_push (nb, etherhdr_size);
91 eth = (struct etherhdr *) nb->data;
92 @@ -76,6 +86,19 @@ send_ethernet_packet (struct grub_net_ne
94 inf->card->opened = 1;
97 + /* Check if a vlan-tag is needed. */
100 + /* Move eth type to the right */
101 + grub_memcpy((char *) nb->data + etherhdr_size - 2,
102 + (char *) nb->data + etherhdr_size - 6, 2);
104 + /* Add the tag in the middle */
105 + grub_memcpy((char *) nb->data + etherhdr_size - 6,
109 return inf->card->driver->send (inf->card, nb);
112 @@ -90,10 +113,23 @@ grub_net_recv_ethernet_packet (struct gr
113 grub_net_link_level_address_t hwaddress;
114 grub_net_link_level_address_t src_hwaddress;
116 + grub_uint8_t etherhdr_size = sizeof (*eth);
118 + grub_uint16_t vlantag_identifier = 0;
119 + grub_memcpy (&vlantag_identifier, nb->data + etherhdr_size - 2, 2);
121 + /* Check if a vlan-tag is present. */
122 + if (vlantag_identifier == VLANTAG_IDENTIFIER)
124 + etherhdr_size += 4;
125 + /* Move eth type to the original position */
126 + grub_memcpy((char *) nb->data + etherhdr_size - 6,
127 + (char *) nb->data + etherhdr_size - 2, 2);
130 eth = (struct etherhdr *) nb->data;
131 type = grub_be_to_cpu16 (eth->type);
132 - err = grub_netbuff_pull (nb, sizeof (*eth));
133 + err = grub_netbuff_pull (nb, etherhdr_size);
137 diff -urNp grub-2.02-rc1.orig/include/grub/ieee1275/ieee1275.h grub-2.02-rc1/include/grub/ieee1275/ieee1275.h
138 --- grub-2.02-rc1.orig/include/grub/ieee1275/ieee1275.h 2017-02-08 15:06:05.445317447 +0000
139 +++ grub-2.02-rc1/include/grub/ieee1275/ieee1275.h 2017-02-08 15:06:17.787317308 +0000
140 @@ -227,6 +227,7 @@ char *EXPORT_FUNC(grub_ieee1275_get_alia
141 char *EXPORT_FUNC(grub_ieee1275_canonicalise_devname) (const char *path);
142 char *EXPORT_FUNC(grub_ieee1275_get_device_type) (const char *path);
143 char *EXPORT_FUNC(grub_ieee1275_get_devname) (const char *path);
144 +int EXPORT_FUNC(grub_ieee1275_parse_net_options) (const char *path);
146 void EXPORT_FUNC(grub_ieee1275_devalias_init_iterator) (struct grub_ieee1275_devalias *alias);
147 void EXPORT_FUNC(grub_ieee1275_devalias_free) (struct grub_ieee1275_devalias *alias);
148 diff -urNp grub-2.02-rc1.orig/include/grub/net.h grub-2.02-rc1/include/grub/net.h
149 --- grub-2.02-rc1.orig/include/grub/net.h 2017-02-08 15:06:05.446317447 +0000
150 +++ grub-2.02-rc1/include/grub/net.h 2017-02-08 15:06:17.788317308 +0000
151 @@ -561,4 +561,6 @@ extern char *grub_net_default_server;
152 #define GRUB_NET_INTERVAL 400
153 #define GRUB_NET_INTERVAL_ADDITION 20
155 +#define VLANTAG_IDENTIFIER 0x8100
157 #endif /* ! GRUB_NET_HEADER */