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
=== modified file 'configure.ac'
--- configure.ac 2014-02-18 19:19:05 +0000
+++ configure.ac 2014-12-22 19:40:17 +0000
@@ -249,17 +249,6 @@
249fi249fi
250250
251251
252# libnetlink.h is required
253AC_CHECK_HEADERS([libnetlink.h], [], [], [[#include <sys/socket.h>
254#include <stdio.h>]])
255if test "x$ac_cv_header_libnetlink_h" != "xyes" ; then
256 echo
257 echo "ERROR: libnetlink.h header not found"
258 echo
259 echo "Please install iproute2 and its header files."
260 echo
261 exit 1
262fi
263# check whether rtnl_talk() takes 5 or 7 arguments252# check whether rtnl_talk() takes 5 or 7 arguments
264AC_MSG_CHECKING([how many arguments rtnl_talk takes])253AC_MSG_CHECKING([how many arguments rtnl_talk takes])
265AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>254AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
266255
=== modified file 'contrib/packaging/debian/control'
--- contrib/packaging/debian/control 2013-09-20 12:44:57 +0000
+++ contrib/packaging/debian/control 2014-12-22 19:40:17 +0000
@@ -1,7 +1,8 @@
1Source: iprohc1Source: iprohc
2Priority: optional2Priority: optional
3Maintainer: Viveris Technologies3Maintainer: Viveris Technologies
4Build-Depends: debhelper (>= 7.0.15), libtool, iproute-dev, librohc-dev, libgnutls-dev, libyaml-dev4Build-Depends: debhelper (>= 7.0.15), libtool, librohc-dev, libgnutls-dev, libyaml-dev
5Depends: ${misc:Depends}, iproute
5Standards-Version: 3.8.46Standards-Version: 3.8.4
6Section: libs7Section: libs
78
89
=== modified file 'src/client/messages.c'
--- src/client/messages.c 2014-03-07 16:18:54 +0000
+++ src/client/messages.c 2014-12-22 19:40:17 +0000
@@ -231,7 +231,7 @@
231 }231 }
232232
233 /* set the IPv4 address on the TUN interface */233 /* set the IPv4 address on the TUN interface */
234 is_ok = set_ip4(client->tun_itf_id, tp.local_address, 24);234 is_ok = set_ip4(client->tun_name, tp.local_address, 24);
235 if(!is_ok)235 if(!is_ok)
236 {236 {
237 trace(LOG_ERR, "failed to set IP address on TUN interface");237 trace(LOG_ERR, "failed to set IP address on TUN interface");
238238
=== modified file 'src/common/Makefile.am'
--- src/common/Makefile.am 2013-12-12 16:09:48 +0000
+++ src/common/Makefile.am 2014-12-22 19:40:17 +0000
@@ -15,8 +15,7 @@
1515
16libiprohc_common_la_LIBADD = \16libiprohc_common_la_LIBADD = \
17 -lgnutls \17 -lgnutls \
18 -lrohc \18 -lrohc
19 -lnetlink
2019
21libiprohc_common_la_LDFLAGS = \20libiprohc_common_la_LDFLAGS = \
22 $(configure_ldflags)21 $(configure_ldflags)
2322
=== modified file 'src/common/tun_helpers.c'
--- src/common/tun_helpers.c 2013-12-12 16:15:24 +0000
+++ src/common/tun_helpers.c 2014-12-22 19:40:17 +0000
@@ -30,7 +30,6 @@
30#include <unistd.h>30#include <unistd.h>
31#include <string.h>31#include <string.h>
32#include <netinet/ip.h>32#include <netinet/ip.h>
33#include <libnetlink.h>
3433
35#include "log.h"34#include "log.h"
36#include "tun_helpers.h"35#include "tun_helpers.h"
@@ -256,72 +255,26 @@
256}255}
257256
258257
259bool set_ip4(int iface_index, uint32_t address, uint8_t network)258bool set_ip4(const char * const iface_name, uint32_t address, uint8_t network)
260{259{
261 bool is_success = false;260 char set_ip_cmd[128];
262 int ret;261 int ret;
263 struct {262
264 struct nlmsghdr nh;263 if((ret = snprintf(set_ip_cmd, sizeof set_ip_cmd,
265 struct ifaddrmsg ip;264 "ip addr add %u.%u.%u.%u/%u dev %s",
266 char buf[256];265 (ntohl(address) >> 24) & 0xff, (ntohl(address) >> 16) & 0xff,
267 } req;266 (ntohl(address) >> 8) & 0xff, (ntohl(address) >> 0) & 0xff,
268 struct rtnl_handle rth = { .fd = -1 };267 network, iface_name)) < 0) {
269 uint32_t *ip_data;268 trace(LOG_ERR, "set_ip4: snprintf(set_ip_cmd, ...) returned %d", ret);
270269 return false;
271 ret = rtnl_open(&rth, 0);270 }
272 if(ret < 0)271
273 {272 if((ret = system(set_ip_cmd)) != 0) {
274 trace(LOG_ERR, "failed to open RTNL socket (code %d)", ret);273 trace(LOG_ERR, "set_ip4: failed to run `%s` (code %d)", set_ip_cmd, ret);
275 goto error;274 return false;
276 }275 }
277276
278 ip_data = calloc(8, sizeof(uint32_t));277 return true;
279 if(ip_data == NULL)
280 {
281 trace(LOG_ERR, "failed to allocate memory for setting IPv4 address");
282 goto close_rtnl;
283 }
284 ip_data[0] = address;
285
286 /* initialize netlink request */
287 memset(&req, 0, sizeof(req));
288 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
289 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL;
290 req.nh.nlmsg_type = RTM_NEWADDR;
291
292 /* ifaddrmsg info */
293 req.ip.ifa_family = AF_INET; /* IPv4 */
294 req.ip.ifa_prefixlen = network;
295 req.ip.ifa_index = iface_index;
296
297 addattr_l(&req.nh, sizeof(req), IFA_LOCAL, ip_data, 4);
298 addattr_l(&req.nh, sizeof(req), IFA_ADDRESS, ip_data, 4);
299
300 /* GOGOGO */
301#if RTNL_TALK_PARAMS == 5
302 ret = rtnl_talk(&rth, &req.nh, 0, 0, NULL);
303#elif RTNL_TALK_PARAMS == 7
304 ret = rtnl_talk(&rth, &req.nh, 0, 0, NULL, NULL, NULL);
305#else
306# error "unsupported version of rtnl_talk()"
307#endif
308 if(ret < 0)
309 {
310 trace(LOG_ERR, "failed to set IPv4 address %u.%u.%u.%u/%u (code %d)",
311 (ntohl(address) >> 24) & 0xff, (ntohl(address) >> 16) & 0xff,
312 (ntohl(address) >> 8) & 0xff, (ntohl(address) >> 0) & 0xff,
313 network, ret);
314 goto free_ip_data;
315 }
316
317 is_success = true;
318
319free_ip_data:
320 free(ip_data);
321close_rtnl:
322 rtnl_close(&rth);
323error:
324 return is_success;
325}278}
326279
327280
328281
=== modified file 'src/common/tun_helpers.h'
--- src/common/tun_helpers.h 2013-12-12 16:15:24 +0000
+++ src/common/tun_helpers.h 2014-12-22 19:40:17 +0000
@@ -29,7 +29,7 @@
29 size_t *const tun_itf_mtu)29 size_t *const tun_itf_mtu)
30 __attribute__((warn_unused_result));30 __attribute__((warn_unused_result));
3131
32bool set_ip4(int iface_index, uint32_t address, uint8_t network);32bool set_ip4(const char * const iface_name, uint32_t address, uint8_t network);
3333
34int create_raw(const int fwmark);34int create_raw(const int fwmark);
3535
3636
=== modified file 'src/server/server.c'
--- src/server/server.c 2014-03-07 16:18:54 +0000
+++ src/server/server.c 2014-12-22 19:40:17 +0000
@@ -58,6 +58,8 @@
58 } \58 } \
59 while(0)59 while(0)
6060
61#define TUN_IF_NAME "tun_ipip"
62
6163
62int log_max_priority = LOG_INFO;64int log_max_priority = LOG_INFO;
63bool iprohc_log_stderr = true;65bool iprohc_log_stderr = true;
@@ -456,7 +458,7 @@
456458
457 /* TUN create */459 /* TUN create */
458 trace(LOG_INFO, "[main] create TUN interface");460 trace(LOG_INFO, "[main] create TUN interface");
459 tun = create_tun("tun_ipip", server_opts.basedev,461 tun = create_tun(TUN_IF_NAME, server_opts.basedev,
460 &tun_itf_id, &basedev_mtu, &tun_itf_mtu);462 &tun_itf_id, &basedev_mtu, &tun_itf_mtu);
461 if(tun < 0)463 if(tun < 0)
462 {464 {
@@ -464,7 +466,7 @@
464 goto close_tcp;466 goto close_tcp;
465 }467 }
466468
467 is_ok = set_ip4(tun_itf_id, server_opts.local_address, 24);469 is_ok = set_ip4(TUN_IF_NAME, server_opts.local_address, 24);
468 if(!is_ok)470 if(!is_ok)
469 {471 {
470 trace(LOG_ERR, "[main] failed to set IPv4 address on TUN interface");472 trace(LOG_ERR, "[main] failed to set IPv4 address on TUN interface");

Subscribers

People subscribed via source and target branches