Merge lp:~shamrin/rohc/iprohc into lp:rohc/iprohc-main

Proposed by ash
Status: Needs review
Proposed branch: lp:~shamrin/rohc/iprohc
Merge into: lp:rohc/iprohc-main
Diff against target: 209 lines (+27/-83)
7 files modified
configure.ac (+0/-11)
contrib/packaging/debian/control (+2/-1)
src/client/messages.c (+1/-1)
src/common/Makefile.am (+1/-2)
src/common/tun_helpers.c (+18/-65)
src/common/tun_helpers.h (+1/-1)
src/server/server.c (+4/-2)
To merge this branch: bzr merge lp:~shamrin/rohc/iprohc
Reviewer Review Type Date Requested Status
Didier Barvaux Pending
Review via email: mp+245318@code.launchpad.net

Description of the change

Ubuntu 14.04 compatibility.

P.S. Sorry for creating an erroneous proposal to merge iprohc into rohc. I've removed it and I hope this merge proposal is correct.

To post a comment you must log in.
lp:~shamrin/rohc/iprohc updated
186. By ash

Move iproute debian dependency from build-time to run-time

187. By ash

add {misc:depends}

Unmerged revisions

187. By ash

add {misc:depends}

186. By ash

Move iproute debian dependency from build-time to run-time

185. By ash

Ubuntu 14.04+ compatibility

Get rid of iproute-dev/libnetlink.h dependency, replacing it with
system("ip addr add...") call. Ubuntu 14.04 doesn't provide iproute-dev
package anymore. In contrast, `ip` command (from `iproute2` package)
seems to be available everywhere.

As a bonus this greatly simplifies set_ip4 function.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2014-02-18 19:19:05 +0000
3+++ configure.ac 2014-12-22 19:40:17 +0000
4@@ -249,17 +249,6 @@
5 fi
6
7
8-# libnetlink.h is required
9-AC_CHECK_HEADERS([libnetlink.h], [], [], [[#include <sys/socket.h>
10-#include <stdio.h>]])
11-if test "x$ac_cv_header_libnetlink_h" != "xyes" ; then
12- echo
13- echo "ERROR: libnetlink.h header not found"
14- echo
15- echo "Please install iproute2 and its header files."
16- echo
17- exit 1
18-fi
19 # check whether rtnl_talk() takes 5 or 7 arguments
20 AC_MSG_CHECKING([how many arguments rtnl_talk takes])
21 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
22
23=== modified file 'contrib/packaging/debian/control'
24--- contrib/packaging/debian/control 2013-09-20 12:44:57 +0000
25+++ contrib/packaging/debian/control 2014-12-22 19:40:17 +0000
26@@ -1,7 +1,8 @@
27 Source: iprohc
28 Priority: optional
29 Maintainer: Viveris Technologies
30-Build-Depends: debhelper (>= 7.0.15), libtool, iproute-dev, librohc-dev, libgnutls-dev, libyaml-dev
31+Build-Depends: debhelper (>= 7.0.15), libtool, librohc-dev, libgnutls-dev, libyaml-dev
32+Depends: ${misc:Depends}, iproute
33 Standards-Version: 3.8.4
34 Section: libs
35
36
37=== modified file 'src/client/messages.c'
38--- src/client/messages.c 2014-03-07 16:18:54 +0000
39+++ src/client/messages.c 2014-12-22 19:40:17 +0000
40@@ -231,7 +231,7 @@
41 }
42
43 /* set the IPv4 address on the TUN interface */
44- is_ok = set_ip4(client->tun_itf_id, tp.local_address, 24);
45+ is_ok = set_ip4(client->tun_name, tp.local_address, 24);
46 if(!is_ok)
47 {
48 trace(LOG_ERR, "failed to set IP address on TUN interface");
49
50=== modified file 'src/common/Makefile.am'
51--- src/common/Makefile.am 2013-12-12 16:09:48 +0000
52+++ src/common/Makefile.am 2014-12-22 19:40:17 +0000
53@@ -15,8 +15,7 @@
54
55 libiprohc_common_la_LIBADD = \
56 -lgnutls \
57- -lrohc \
58- -lnetlink
59+ -lrohc
60
61 libiprohc_common_la_LDFLAGS = \
62 $(configure_ldflags)
63
64=== modified file 'src/common/tun_helpers.c'
65--- src/common/tun_helpers.c 2013-12-12 16:15:24 +0000
66+++ src/common/tun_helpers.c 2014-12-22 19:40:17 +0000
67@@ -30,7 +30,6 @@
68 #include <unistd.h>
69 #include <string.h>
70 #include <netinet/ip.h>
71-#include <libnetlink.h>
72
73 #include "log.h"
74 #include "tun_helpers.h"
75@@ -256,72 +255,26 @@
76 }
77
78
79-bool set_ip4(int iface_index, uint32_t address, uint8_t network)
80+bool set_ip4(const char * const iface_name, uint32_t address, uint8_t network)
81 {
82- bool is_success = false;
83+ char set_ip_cmd[128];
84 int ret;
85- struct {
86- struct nlmsghdr nh;
87- struct ifaddrmsg ip;
88- char buf[256];
89- } req;
90- struct rtnl_handle rth = { .fd = -1 };
91- uint32_t *ip_data;
92-
93- ret = rtnl_open(&rth, 0);
94- if(ret < 0)
95- {
96- trace(LOG_ERR, "failed to open RTNL socket (code %d)", ret);
97- goto error;
98- }
99-
100- ip_data = calloc(8, sizeof(uint32_t));
101- if(ip_data == NULL)
102- {
103- trace(LOG_ERR, "failed to allocate memory for setting IPv4 address");
104- goto close_rtnl;
105- }
106- ip_data[0] = address;
107-
108- /* initialize netlink request */
109- memset(&req, 0, sizeof(req));
110- req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
111- req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL;
112- req.nh.nlmsg_type = RTM_NEWADDR;
113-
114- /* ifaddrmsg info */
115- req.ip.ifa_family = AF_INET; /* IPv4 */
116- req.ip.ifa_prefixlen = network;
117- req.ip.ifa_index = iface_index;
118-
119- addattr_l(&req.nh, sizeof(req), IFA_LOCAL, ip_data, 4);
120- addattr_l(&req.nh, sizeof(req), IFA_ADDRESS, ip_data, 4);
121-
122- /* GOGOGO */
123-#if RTNL_TALK_PARAMS == 5
124- ret = rtnl_talk(&rth, &req.nh, 0, 0, NULL);
125-#elif RTNL_TALK_PARAMS == 7
126- ret = rtnl_talk(&rth, &req.nh, 0, 0, NULL, NULL, NULL);
127-#else
128-# error "unsupported version of rtnl_talk()"
129-#endif
130- if(ret < 0)
131- {
132- trace(LOG_ERR, "failed to set IPv4 address %u.%u.%u.%u/%u (code %d)",
133- (ntohl(address) >> 24) & 0xff, (ntohl(address) >> 16) & 0xff,
134- (ntohl(address) >> 8) & 0xff, (ntohl(address) >> 0) & 0xff,
135- network, ret);
136- goto free_ip_data;
137- }
138-
139- is_success = true;
140-
141-free_ip_data:
142- free(ip_data);
143-close_rtnl:
144- rtnl_close(&rth);
145-error:
146- return is_success;
147+
148+ if((ret = snprintf(set_ip_cmd, sizeof set_ip_cmd,
149+ "ip addr add %u.%u.%u.%u/%u dev %s",
150+ (ntohl(address) >> 24) & 0xff, (ntohl(address) >> 16) & 0xff,
151+ (ntohl(address) >> 8) & 0xff, (ntohl(address) >> 0) & 0xff,
152+ network, iface_name)) < 0) {
153+ trace(LOG_ERR, "set_ip4: snprintf(set_ip_cmd, ...) returned %d", ret);
154+ return false;
155+ }
156+
157+ if((ret = system(set_ip_cmd)) != 0) {
158+ trace(LOG_ERR, "set_ip4: failed to run `%s` (code %d)", set_ip_cmd, ret);
159+ return false;
160+ }
161+
162+ return true;
163 }
164
165
166
167=== modified file 'src/common/tun_helpers.h'
168--- src/common/tun_helpers.h 2013-12-12 16:15:24 +0000
169+++ src/common/tun_helpers.h 2014-12-22 19:40:17 +0000
170@@ -29,7 +29,7 @@
171 size_t *const tun_itf_mtu)
172 __attribute__((warn_unused_result));
173
174-bool set_ip4(int iface_index, uint32_t address, uint8_t network);
175+bool set_ip4(const char * const iface_name, uint32_t address, uint8_t network);
176
177 int create_raw(const int fwmark);
178
179
180=== modified file 'src/server/server.c'
181--- src/server/server.c 2014-03-07 16:18:54 +0000
182+++ src/server/server.c 2014-12-22 19:40:17 +0000
183@@ -58,6 +58,8 @@
184 } \
185 while(0)
186
187+#define TUN_IF_NAME "tun_ipip"
188+
189
190 int log_max_priority = LOG_INFO;
191 bool iprohc_log_stderr = true;
192@@ -456,7 +458,7 @@
193
194 /* TUN create */
195 trace(LOG_INFO, "[main] create TUN interface");
196- tun = create_tun("tun_ipip", server_opts.basedev,
197+ tun = create_tun(TUN_IF_NAME, server_opts.basedev,
198 &tun_itf_id, &basedev_mtu, &tun_itf_mtu);
199 if(tun < 0)
200 {
201@@ -464,7 +466,7 @@
202 goto close_tcp;
203 }
204
205- is_ok = set_ip4(tun_itf_id, server_opts.local_address, 24);
206+ is_ok = set_ip4(TUN_IF_NAME, server_opts.local_address, 24);
207 if(!is_ok)
208 {
209 trace(LOG_ERR, "[main] failed to set IPv4 address on TUN interface");

Subscribers

People subscribed via source and target branches