]> TLD Linux GIT Repositories - packages/grub2.git/blob - add-vlan-tag-support.patch
- PLD merge - grub 2.02 beta 2, no changes
[packages/grub2.git] / add-vlan-tag-support.patch
1 diff -dur grub-2.00.git20131218.orig/grub-core/kern/ieee1275/init.c grub-2.00.git20131218/grub-core/kern/ieee1275/init.c
2 --- grub-2.00.git20131218.orig/grub-core/kern/ieee1275/init.c   2013-12-18 13:11:29.000000000 +0100
3 +++ grub-2.00.git20131218/grub-core/kern/ieee1275/init.c        2013-12-18 14:39:17.000000000 +0100
4 @@ -118,6 +118,7 @@
5        char *dev, *canon;
6        char *ptr;
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 Only in grub-2.00.git20131218/grub-core/kern/ieee1275: init.c.orig
13 diff -dur grub-2.00.git20131218.orig/grub-core/kern/ieee1275/openfw.c grub-2.00.git20131218/grub-core/kern/ieee1275/openfw.c
14 --- grub-2.00.git20131218.orig/grub-core/kern/ieee1275/openfw.c 2013-12-18 13:11:29.000000000 +0100
15 +++ grub-2.00.git20131218/grub-core/kern/ieee1275/openfw.c      2013-12-18 14:39:17.000000000 +0100
16 @@ -23,6 +23,7 @@
17  #include <grub/mm.h>
18  #include <grub/ieee1275/ieee1275.h>
19  #include <grub/net.h>
20 +#include <grub/env.h>
21  
22  enum grub_ieee1275_parse_type
23  {
24 @@ -451,6 +452,35 @@
25    return ret;
26  }
27  
28 +int
29 +grub_ieee1275_parse_net_options (const char *path)
30 +{
31 +  char *comma;
32 +  char *args;
33 +  char *option = 0;
34 +
35 +  args = grub_ieee1275_get_devargs (path);
36 +  if (!args)
37 +    /* There is no option.  */
38 +    return -1;
39 +
40 +  do
41 +    {
42 +      comma = grub_strchr (args, ',');
43 +      if (! comma)
44 +        option = grub_strdup (args);
45 +      else
46 +        option = grub_strndup (args, (grub_size_t)(comma - args));
47 +      args = comma + 1;
48 +
49 +      if (! grub_strncmp(option, "vtag", 4))
50 +          grub_env_set ("vlan-tag", option + grub_strlen("vtag="));
51 +
52 +    } while (comma);
53 +
54 +  return 0;
55 +}
56 +
57  char *
58  grub_ieee1275_get_device_type (const char *path)
59  {
60 Only in grub-2.00.git20131218/grub-core/kern/ieee1275: openfw.c.orig
61 diff -dur grub-2.00.git20131218.orig/grub-core/net/ethernet.c grub-2.00.git20131218/grub-core/net/ethernet.c
62 --- grub-2.00.git20131218.orig/grub-core/net/ethernet.c 2013-12-18 13:11:29.000000000 +0100
63 +++ grub-2.00.git20131218/grub-core/net/ethernet.c      2013-12-18 14:39:17.000000000 +0100
64 @@ -23,6 +23,7 @@
65  #include <grub/net/arp.h>
66  #include <grub/net/netbuff.h>
67  #include <grub/net.h>
68 +#include <grub/env.h>
69  #include <grub/time.h>
70  #include <grub/net/arp.h>
71  
72 @@ -56,10 +57,19 @@
73  {
74    struct etherhdr *eth;
75    grub_err_t err;
76 +  grub_uint32_t vlantag = 0;
77 +  grub_uint8_t etherhdr_size;
78  
79 -  COMPILE_TIME_ASSERT (sizeof (*eth) < GRUB_NET_MAX_LINK_HEADER_SIZE);
80 +  etherhdr_size = sizeof (*eth);
81 +  COMPILE_TIME_ASSERT (sizeof (*eth) + 4 < GRUB_NET_MAX_LINK_HEADER_SIZE);
82  
83 -  err = grub_netbuff_push (nb, sizeof (*eth));
84 +  const char *vlantag_text = grub_env_get ("vlan-tag");
85 +  if (vlantag_text != 0) {
86 +      etherhdr_size += 4;
87 +      vlantag = grub_strtoul (vlantag_text, 0, 16);
88 +  }
89 +
90 +  err = grub_netbuff_push (nb, etherhdr_size);
91    if (err)
92      return err;
93    eth = (struct etherhdr *) nb->data;
94 @@ -76,6 +86,19 @@
95         return err;
96        inf->card->opened = 1;
97      }
98 +
99 +  /* Check if a vlan-tag is needed. */
100 +  if (vlantag != 0)
101 +    {
102 +      /* Move eth type to the right */
103 +      grub_memcpy((char *) nb->data + etherhdr_size - 2,
104 +                  (char *) nb->data + etherhdr_size - 6, 2);
105 +
106 +      /* Add the tag in the middle */
107 +      grub_memcpy((char *) nb->data + etherhdr_size - 6,
108 +                  &vlantag, 4);
109 +    }
110 +
111    return inf->card->driver->send (inf->card, nb);
112  }
113  
114 @@ -90,10 +113,23 @@
115    grub_net_link_level_address_t hwaddress;
116    grub_net_link_level_address_t src_hwaddress;
117    grub_err_t err;
118 +  grub_uint8_t etherhdr_size = sizeof (*eth);
119 +
120 +  grub_uint16_t vlantag_identifier = 0;
121 +  grub_memcpy (&vlantag_identifier, nb->data + etherhdr_size - 2, 2);
122 +
123 +  /* Check if a vlan-tag is present. */
124 +  if (vlantag_identifier == VLANTAG_IDENTIFIER)
125 +    {
126 +      etherhdr_size += 4;
127 +      /* Move eth type to the original position */
128 +      grub_memcpy((char *) nb->data + etherhdr_size - 6,
129 +                  (char *) nb->data + etherhdr_size - 2, 2);
130 +    }
131  
132    eth = (struct etherhdr *) nb->data;
133    type = grub_be_to_cpu16 (eth->type);
134 -  err = grub_netbuff_pull (nb, sizeof (*eth));
135 +  err = grub_netbuff_pull (nb, etherhdr_size);
136    if (err)
137      return err;
138  
139 diff -dur grub-2.00.git20131218.orig/include/grub/ieee1275/ieee1275.h grub-2.00.git20131218/include/grub/ieee1275/ieee1275.h
140 --- grub-2.00.git20131218.orig/include/grub/ieee1275/ieee1275.h 2013-12-18 13:11:29.000000000 +0100
141 +++ grub-2.00.git20131218/include/grub/ieee1275/ieee1275.h      2013-12-18 14:40:11.000000000 +0100
142 @@ -226,6 +226,7 @@
143  char *EXPORT_FUNC(grub_ieee1275_canonicalise_devname) (const char *path);
144  char *EXPORT_FUNC(grub_ieee1275_get_device_type) (const char *path);
145  char *EXPORT_FUNC(grub_ieee1275_get_devname) (const char *path);
146 +int EXPORT_FUNC(grub_ieee1275_parse_net_options) (const char *path);
147  
148  void EXPORT_FUNC(grub_ieee1275_devalias_init_iterator) (struct grub_ieee1275_devalias *alias);
149  void EXPORT_FUNC(grub_ieee1275_devalias_free) (struct grub_ieee1275_devalias *alias);
150 diff -dur grub-2.00.git20131218.orig/include/grub/net.h grub-2.00.git20131218/include/grub/net.h
151 --- grub-2.00.git20131218.orig/include/grub/net.h       2013-12-18 13:11:29.000000000 +0100
152 +++ grub-2.00.git20131218/include/grub/net.h    2013-12-18 14:39:18.000000000 +0100
153 @@ -533,4 +533,6 @@
154  #define GRUB_NET_TRIES 40
155  #define GRUB_NET_INTERVAL 400
156  
157 +#define VLANTAG_IDENTIFIER 0x8100
158 +
159  #endif /* ! GRUB_NET_HEADER */
160 Only in grub-2.00.git20131218/include/grub: net.h.orig