File: net-Remove-variables-hooks-when-interface-is-unregisted.patch

package info (click to toggle)
grub2 2.12-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie, trixie-proposed-updates, trixie-updates
  • size: 70,780 kB
  • sloc: ansic: 424,740; asm: 16,228; sh: 9,525; cpp: 2,095; makefile: 1,590; python: 1,468; sed: 431; lex: 393; yacc: 268; awk: 85; lisp: 54; perl: 31
file content (86 lines) | stat: -rw-r--r-- 2,546 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
From: B Horn <b@horn.uk>
Date: Fri, 1 Nov 2024 23:49:48 +0000
Subject: net: Remove variables hooks when interface is unregisted

The grub_net_network_level_interface_unregister(), previously
implemented in a header, did not remove the variables hooks that
were registered in grub_net_network_level_interface_register().
Fix this by implementing the same logic used to register the
variables and move the function into the grub-core/net/net.c.

Signed-off-by: B Horn <b@horn.uk>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Conflicts:
	grub-core/net/net.c
---
 grub-core/net/net.c | 33 +++++++++++++++++++++++++++++++++
 include/grub/net.h  | 11 +----------
 2 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/grub-core/net/net.c b/grub-core/net/net.c
index 9c6c84c..8ff99ff 100644
--- a/grub-core/net/net.c
+++ b/grub-core/net/net.c
@@ -1060,6 +1060,39 @@ grub_net_add_ipv6_local (struct grub_net_network_level_interface *inter,
   return 0;
 }
 
+void
+grub_net_network_level_interface_unregister (struct grub_net_network_level_interface *inter)
+{
+  char *name;
+
+  {
+    char buf[GRUB_NET_MAX_STR_HWADDR_LEN];
+
+    grub_net_hwaddr_to_str (&inter->hwaddress, buf);
+    name = grub_xasprintf ("net_%s_mac", inter->name);
+    if (name != NULL)
+      grub_register_variable_hook (name, NULL, NULL);
+    grub_free (name);
+  }
+
+  {
+    char buf[GRUB_NET_MAX_STR_ADDR_LEN];
+
+    grub_net_addr_to_str (&inter->address, buf);
+    name = grub_xasprintf ("net_%s_ip", inter->name);
+    if (name != NULL)
+      grub_register_variable_hook (name, NULL, NULL);
+    grub_free (name);
+  }
+
+  inter->card->num_ifaces--;
+  *inter->prev = inter->next;
+  if (inter->next)
+    inter->next->prev = inter->prev;
+  inter->next = 0;
+  inter->prev = 0;
+}
+
 grub_err_t
 grub_net_add_ipv4_local (struct grub_net_network_level_interface *inter,
 			 int mask)
diff --git a/include/grub/net.h b/include/grub/net.h
index e7d75b9..3e6a43d 100644
--- a/include/grub/net.h
+++ b/include/grub/net.h
@@ -620,16 +620,7 @@ void grub_bootp_fini (void);
 void grub_dns_init (void);
 void grub_dns_fini (void);
 
-static inline void
-grub_net_network_level_interface_unregister (struct grub_net_network_level_interface *inter)
-{
-  inter->card->num_ifaces--;
-  *inter->prev = inter->next;
-  if (inter->next)
-    inter->next->prev = inter->prev;
-  inter->next = 0;
-  inter->prev = 0;
-}
+void grub_net_network_level_interface_unregister (struct grub_net_network_level_interface *inter);
 
 void
 grub_net_tcp_retransmit (void);