summaryrefslogtreecommitdiffstats
path: root/recipes-connectivity/connman/connman/0001-added-noipconfig-option.patch
diff options
context:
space:
mode:
authorAdrian Dudau <adrian.dudau@enea.com>2016-01-29 14:12:23 +0100
committerNora Björklund <nora.bjorklund@enea.com>2016-02-08 14:30:51 +0100
commitb878cf381de0a0d158f1e97cf8726ea1756fd2fa (patch)
tree24cd38525e85e9de3a58b2a5034f368eb86ec117 /recipes-connectivity/connman/connman/0001-added-noipconfig-option.patch
parentde0b35a0d18ec23b7be6b0bde88b3254c951d6ac (diff)
downloadmeta-el-common-b878cf381de0a0d158f1e97cf8726ea1756fd2fa.tar.gz
connman: Rewrite to a patch to the connman file
The original .bbappend was adding a new "connman" file that replaced the one provided in the original recipe. This meant that any changes in the original file from poky would be overwritten. The .bbappend now patches the connman file so that any changes in it are either included or caught with merge conflict. To achieve this I did an artifice of copying the connman file in S to be patched by do_patch, then copied it back in WORKDIR to be installed on target by do_install. Also renamed the recipe .bbappend to cover all versions of connman and renamed the files folder. Signed-off-by: Adrian Dudau <adrian.dudau@enea.com> Signed-off-by: Nora Björklund <nora.bjorklund@enea.com>
Diffstat (limited to 'recipes-connectivity/connman/connman/0001-added-noipconfig-option.patch')
-rw-r--r--recipes-connectivity/connman/connman/0001-added-noipconfig-option.patch353
1 files changed, 353 insertions, 0 deletions
diff --git a/recipes-connectivity/connman/connman/0001-added-noipconfig-option.patch b/recipes-connectivity/connman/connman/0001-added-noipconfig-option.patch
new file mode 100644
index 0000000..d86b778
--- /dev/null
+++ b/recipes-connectivity/connman/connman/0001-added-noipconfig-option.patch
@@ -0,0 +1,353 @@
1Disabling interface index for desired interfaces so that all methods dealing
2with those indexes (ifup, ifdown, new route, new gateway, etc.) will exit
3immediately. This is obtained through a new option called "noipconfig".
4Helpful when dealing with NFS dhcp method like:
5root=/dev/nfs rw nfsroot=172.21.3.8:/unix/enea_linux_rootfs/user/p2041rdb \
6 ip=dhcp console=ttyS0,115200 memmap=16M$0xf7000000 \
7 mem=4080M max_addr=f6ffffff
8
9This ports the https://www.cvg.de/people/ensc/0001-added-noipconfig-option.patch
10 change to connman_1.25. In http://patchwork.openembedded.org/patch/57539/ that
11 change is considered too intrusive and specific to be upstreamed.
12
13Signed-off-by: George Nita <george.nita@enea.com>
14Upstream-Status: Not Applicable
15
16
17diff --git a/src/connman.h b/src/connman.h
18index db6461f..8f4f4d0 100644
19--- a/src/connman.h
20+++ b/src/connman.h
21@@ -544,7 +544,8 @@ void __connman_technology_notify_regdom_by_device(struct connman_device *device,
22
23 #include <connman/device.h>
24
25-int __connman_device_init(const char *device, const char *nodevice);
26+int __connman_device_init(const char *device, const char *nodevice,
27+ const char *noipconfig);
28 void __connman_device_cleanup(void);
29
30 void __connman_device_list(DBusMessageIter *iter, void *user_data);
31diff --git a/src/device.c b/src/device.c
32index c0683ab..6582c51 100644
33--- a/src/device.c
34+++ b/src/device.c
35@@ -37,6 +37,7 @@
36 static GSList *device_list = NULL;
37 static gchar **device_filter = NULL;
38 static gchar **nodevice_filter = NULL;
39+static gchar **noipconfig_filter = NULL;
40
41 enum connman_pending_type {
42 PENDING_NONE = 0,
43@@ -1314,6 +1315,20 @@ done:
44 return device;
45 }
46
47+static bool __connman_device_noipconfig(const char *devname)
48+{
49+ char **pattern;
50+
51+ for (pattern = noipconfig_filter; *pattern; pattern++) {
52+ if (g_pattern_match_simple(*pattern, devname) == TRUE) {
53+ DBG("do not configure device %s", devname);
54+ return TRUE;
55+ }
56+ }
57+
58+ return FALSE;
59+}
60+
61 bool __connman_device_isfiltered(const char *devname)
62 {
63 char **pattern;
64@@ -1403,6 +1418,9 @@ static void cleanup_devices(void)
65 if (index < 0)
66 continue;
67
68+ if (__connman_device_noipconfig(interfaces[i]))
69+ __connman_inet_disable_index(index);
70+
71 if (!__connman_inet_get_address_netmask(index, &sin_addr,
72 &sin_mask)) {
73 char *address = g_strdup(inet_ntoa(sin_addr.sin_addr));
74@@ -1435,7 +1453,8 @@ static void cleanup_devices(void)
75 g_strfreev(interfaces);
76 }
77
78-int __connman_device_init(const char *device, const char *nodevice)
79+int __connman_device_init(const char *device, const char *nodevice,
80+ const char *noipconfig)
81 {
82 DBG("");
83
84@@ -1445,6 +1464,9 @@ int __connman_device_init(const char *device, const char *nodevice)
85 if (nodevice)
86 nodevice_filter = g_strsplit(nodevice, ",", -1);
87
88+ if (noipconfig != NULL)
89+ noipconfig_filter = g_strsplit(noipconfig, ",", -1);
90+
91 cleanup_devices();
92
93 return 0;
94diff --git a/src/inet.c b/src/inet.c
95index fb37143..d1f2c2f 100644
96--- a/src/inet.c
97+++ b/src/inet.c
98@@ -55,6 +55,45 @@
99 ((struct rtattr *) (((uint8_t*) (nmsg)) + \
100 NLMSG_ALIGN((nmsg)->nlmsg_len)))
101
102+static GHashTable *g_disabled_indices;
103+
104+static guint g_intptr_hash(gconstpointer p)
105+{
106+ uintptr_t v = (uintptr_t)p;
107+ return g_int_hash(&v);
108+}
109+
110+static gboolean g_intptr_equal(gconstpointer p1,
111+ gconstpointer p2)
112+{
113+ uintptr_t v1 = (uintptr_t)p1;
114+ uintptr_t v2 = (uintptr_t)p2;
115+
116+ return g_int_equal(&v1, &v2);
117+}
118+
119+void __connman_inet_disable_index(int index)
120+{
121+ connman_info("disabling interface #%d for ipconfig", index);
122+
123+ if (g_disabled_indices == NULL)
124+ g_disabled_indices = g_hash_table_new_full(g_intptr_hash,
125+ g_intptr_equal,
126+ NULL, NULL);
127+
128+ g_hash_table_add(g_disabled_indices, (void *)index);
129+}
130+
131+static bool __connman_inet_is_disabled_index(int index)
132+{
133+ bool rc;
134+
135+ rc = (g_disabled_indices != NULL &&
136+ g_hash_table_contains(g_disabled_indices, (void *)index));
137+
138+ return rc;
139+}
140+
141 int __connman_inet_rtnl_addattr_l(struct nlmsghdr *n, size_t max_length,
142 int type, const void *data, size_t data_length)
143 {
144@@ -98,6 +137,11 @@ int __connman_inet_modify_address(int cmd, int flags,
145 "prefixlen %hhu broadcast %s", cmd, flags, index, family,
146 address, peer, prefixlen, broadcast);
147
148+ if (__connman_inet_is_disabled_index(index)) {
149+ connman_info("index disabled; skipping %s", __func__);
150+ return 0;
151+ }
152+
153 if (!address)
154 return -EINVAL;
155
156@@ -275,6 +319,11 @@ int connman_inet_ifup(int index)
157 struct ifreq ifr;
158 int sk, err;
159
160+ if (__connman_inet_is_disabled_index(index)) {
161+ connman_info("index disabled; skipping %s", __func__);
162+ return 0;
163+ }
164+
165 sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
166 if (sk < 0)
167 return -errno;
168@@ -318,6 +367,11 @@ int connman_inet_ifdown(int index)
169 struct sockaddr_in *addr;
170 int sk, err;
171
172+ if (__connman_inet_is_disabled_index(index)) {
173+ connman_info("index disabled; skipping %s", __func__);
174+ return 0;
175+ }
176+
177 sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
178 if (sk < 0)
179 return -errno;
180@@ -519,6 +573,11 @@ int connman_inet_add_network_route(int index, const char *host,
181 DBG("index %d host %s gateway %s netmask %s", index,
182 host, gateway, netmask);
183
184+ if (__connman_inet_is_disabled_index(index)) {
185+ connman_info("index disabled; skipping %s", __func__);
186+ return 0;
187+ }
188+
189 sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
190 if (sk < 0) {
191 err = -errno;
192@@ -589,6 +648,11 @@ int connman_inet_del_network_route(int index, const char *host)
193
194 DBG("index %d host %s", index, host);
195
196+ if (__connman_inet_is_disabled_index(index)) {
197+ connman_info("index disabled; skipping %s", __func__);
198+ return 0;
199+ }
200+
201 sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
202 if (sk < 0) {
203 err = -errno;
204@@ -637,6 +701,11 @@ int connman_inet_del_ipv6_network_route(int index, const char *host,
205
206 DBG("index %d host %s", index, host);
207
208+ if (__connman_inet_is_disabled_index(index)) {
209+ connman_info("index disabled; skipping %s", __func__);
210+ return 0;
211+ }
212+
213 if (!host)
214 return -EINVAL;
215
216@@ -687,6 +756,11 @@ int connman_inet_add_ipv6_network_route(int index, const char *host,
217
218 DBG("index %d host %s gateway %s", index, host, gateway);
219
220+ if (__connman_inet_is_disabled_index(index)) {
221+ connman_info("index disabled; skipping %s", __func__);
222+ return 0;
223+ }
224+
225 if (!host)
226 return -EINVAL;
227
228@@ -741,6 +815,11 @@ int connman_inet_clear_ipv6_gateway_address(int index, const char *gateway)
229
230 DBG("index %d gateway %s", index, gateway);
231
232+ if (__connman_inet_is_disabled_index(index)) {
233+ connman_info("index disabled; skipping clear_ipv6_gateway operation");
234+ return 0;
235+ }
236+
237 if (!gateway)
238 return -EINVAL;
239
240@@ -784,6 +863,11 @@ int connman_inet_set_gateway_interface(int index)
241
242 DBG("index %d", index);
243
244+ if (__connman_inet_is_disabled_index(index)) {
245+ connman_info("index disabled; skipping %s", __func__);
246+ return 0;
247+ }
248+
249 sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
250 if (sk < 0) {
251 err = -errno;
252@@ -837,6 +921,11 @@ int connman_inet_set_ipv6_gateway_interface(int index)
253
254 DBG("index %d", index);
255
256+ if (__connman_inet_is_disabled_index(index)) {
257+ connman_info("index disabled; skipping %s", __func__);
258+ return 0;
259+ }
260+
261 sk = socket(PF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0);
262 if (sk < 0) {
263 err = -errno;
264@@ -889,6 +978,11 @@ int connman_inet_clear_gateway_address(int index, const char *gateway)
265
266 DBG("index %d gateway %s", index, gateway);
267
268+ if (__connman_inet_is_disabled_index(index)) {
269+ connman_info("index disabled; skipping %s", __func__);
270+ return 0;
271+ }
272+
273 sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
274 if (sk < 0) {
275 err = -errno;
276@@ -946,6 +1040,11 @@ int connman_inet_clear_gateway_interface(int index)
277
278 DBG("index %d", index);
279
280+ if (__connman_inet_is_disabled_index(index)) {
281+ connman_info("index disabled; skipping %s", __func__);
282+ return 0;
283+ }
284+
285 sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
286 if (sk < 0) {
287 err = -errno;
288@@ -999,6 +1098,11 @@ int connman_inet_clear_ipv6_gateway_interface(int index)
289
290 DBG("index %d", index);
291
292+ if (__connman_inet_is_disabled_index(index)) {
293+ connman_info("index disabled; skipping %s", __func__);
294+ return 0;
295+ }
296+
297 sk = socket(PF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0);
298 if (sk < 0) {
299 err = -errno;
300@@ -1059,6 +1163,11 @@ bool connman_inet_compare_subnet(int index, const char *host)
301 return -1;
302 host_addr = _host_addr.s_addr;
303
304+ if (__connman_inet_is_disabled_index(index)) {
305+ connman_info("index disabled; skipping %s", __func__);
306+ return 0;
307+ }
308+
309 sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
310 if (sk < 0)
311 return false;
312@@ -1159,6 +1268,11 @@ int connman_inet_set_mtu(int index, int mtu)
313 struct ifreq ifr;
314 int sk, err;
315
316+ if (__connman_inet_is_disabled_index(index)) {
317+ connman_info("index disabled; skipping %s", __func__);
318+ return 0;
319+ }
320+
321 sk = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
322 if (sk < 0)
323 return sk;
324diff --git a/src/main.c b/src/main.c
325index 7cf6c9a..e06f25c 100644
326--- a/src/main.c
327+++ b/src/main.c
328@@ -453,6 +453,7 @@ static gchar *option_debug = NULL;
329 static gchar *option_device = NULL;
330 static gchar *option_plugin = NULL;
331 static gchar *option_nodevice = NULL;
332+static gchar *option_noipconfig = NULL;
333 static gchar *option_noplugin = NULL;
334 static gchar *option_wifi = NULL;
335 static gboolean option_detach = TRUE;
336@@ -482,6 +483,8 @@ static GOptionEntry options[] = {
337 "Specify networking device or interface", "DEV" },
338 { "nodevice", 'I', 0, G_OPTION_ARG_STRING, &option_nodevice,
339 "Specify networking interface to ignore", "DEV" },
340+ { "noipconfig", 0, 0, G_OPTION_ARG_STRING, &option_noipconfig,
341+ "Specify networking interface which shall not be configured", "DEV" },
342 { "plugin", 'p', 0, G_OPTION_ARG_STRING, &option_plugin,
343 "Specify plugins to load", "NAME,..." },
344 { "noplugin", 'P', 0, G_OPTION_ARG_STRING, &option_noplugin,
345@@ -648,7 +651,7 @@ int main(int argc, char *argv[])
346 __connman_provider_init();
347 __connman_network_init();
348 __connman_config_init();
349- __connman_device_init(option_device, option_nodevice);
350+ __connman_device_init(option_device, option_nodevice, option_noipconfig);
351
352 __connman_ippool_init();
353 __connman_iptables_init();