From patchwork Fri Jun 26 06:55:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 488613 X-Patchwork-Delegate: nbd@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 00C161401E7 for ; Fri, 26 Jun 2015 16:56:02 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=e1OlWNN+; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id AF9BE28A9A9; Fri, 26 Jun 2015 08:55:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id C8BFF2802B3 for ; Fri, 26 Jun 2015 08:55:38 +0200 (CEST) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Fri, 26 Jun 2015 08:55:38 +0200 (CEST) Received: by wicnd19 with SMTP id nd19so8852670wic.1 for ; Thu, 25 Jun 2015 23:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=lk/ECJWUgbF/LaK23Lm3xVpFVULVw3RRCDCgFn32YNc=; b=e1OlWNN+pNa/C4TyDTRO55XFLqhVkRBqAneB9u6lEiE+viGJY1gGi2GU+EmmBhm5v+ G9dip2DQZrYP6fgMwqzizc1/2E4SBBIprW3gcOnFThLQ/0BeGHkGnUDBcfGwaQkHxfNf NOjfkYuP/wq5B9wcSJbFWwx2QNu8GAXfzLVeJO+C5FO1xppvfEj6NTfGxUyYEQtHdNWO LcB8i8g9FeHSZdHk9el1Y9SiMcyd6aY3UdAiaxPX6oub7muFZmMNYtpLGkH+9w1DuJ23 fE9w45eJoBxImGDG7j+9Q7f7ENLb2psPdl3uUPXrkBXsXoaZLjsQxkVMWnPNQneezIBp MjJQ== X-Received: by 10.180.95.10 with SMTP id dg10mr1932490wib.41.1435301748601; Thu, 25 Jun 2015 23:55:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.203.136 with HTTP; Thu, 25 Jun 2015 23:55:29 -0700 (PDT) In-Reply-To: References: From: Alexandru Ardelean Date: Fri, 26 Jun 2015 09:55:29 +0300 Message-ID: To: OpenWrt Development List Subject: [OpenWrt-Devel] Fwd: [packages] netifd: NULL device on network restart (#1476) X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" In case it was missed on the packages Github feed. ---------- Forwarded message ---------- From: philipc Date: Fri, Jun 26, 2015 at 8:29 AM Subject: [packages] netifd: NULL device on network restart (#1476) To: openwrt/packages I'm getting a NULL device access in system_del_address() with the following test configuration: config interface net1 option ifname eth0 option proto static option ipaddr 10.1.1.1 option netmask 255.255.255.255 config interface net2 option ifname eth0 option proto static option ipaddr 10.2.2.2 option netmask 255.255.255.255 The NULL device access occurs when I call 'ubus call network restart'. Here's the backtrace: Program received signal SIGSEGV, Segmentation fault. system_del_address (dev=dev@entry=0x0, addr=addr@entry=0x634d50) at /home/philipc/pkg/netifd/system-linux.c:1509 1509 return system_addr(dev, addr, RTM_DELADDR); (gdb) bt #0 system_del_address (dev=dev@entry=0x0, addr=addr@entry=0x634d50) at /home/philipc/pkg/netifd/system-linux.c:1509 #1 0x0000000000407d3e in interface_update_proto_addr (tree=, node_new=0x0, node_old=0x634d50) at /home/philipc/pkg/netifd/interface-ip.c:539 #2 0x00007ffff7bd6415 in vlist_flush (tree=tree@entry=0x633340) at /home/philipc/pkg/libubox/vlist.c:71 #3 0x00007ffff7bd642f in vlist_flush_all (tree=tree@entry=0x633340) at /home/philipc/pkg/libubox/vlist.c:79 #4 0x000000000040949c in interface_ip_flush (ip=ip@entry=0x633330) at /home/philipc/pkg/netifd/interface-ip.c:1301 #5 0x0000000000405456 in mark_interface_down (iface=iface@entry=0x6331b0) at /home/philipc/pkg/netifd/interface.c:243 #6 0x0000000000406645 in interface_proto_cb (state=, ev=) at /home/philipc/pkg/netifd/interface.c:678 #7 0x000000000040aa86 in interface_proto_event (proto=0x632ae0, cmd=cmd@entry=PROTO_CMD_TEARDOWN, force=force@entry=false) at /home/philipc/pkg/netifd/proto.c:629 #8 0x00000000004054f6 in interface_check_state (iface=0x6331b0) at /home/philipc/pkg/netifd/interface.c:297 #9 0x000000000040c730 in device_broadcast_cb (ctx=0x0, list=0x0) at /home/philipc/pkg/netifd/device.c:287 #10 0x00007ffff7bd660e in safe_list_for_each (head=head@entry=0x633850, cb=cb@entry=0x40c715 , ctx=ctx@entry=0x7fffffffe35c) at /home/philipc/pkg/libubox/safe_list.c:74 #11 0x000000000040c819 in device_broadcast_event (dev=0x633810, ev=) at /home/philipc/pkg/netifd/device.c:296 #12 0x0000000000406d80 in interface_set_down (iface=0x633a30, iface@entry=0x0) at /home/philipc/pkg/netifd/interface.c:1020 #13 0x000000000040472e in netifd_restart () at /home/philipc/pkg/netifd/main.c:225 The problem is that when net1 is brought up, it also brings up all other interfaces using the same device, but device_claim(&iface->main_dev) is not called for these other interfaces. Here's the part of the backtrace for how that happens: #4 0x000000000040549a in __interface_set_up (iface=0x6339c0) at /home/philipc/pkg/netifd/interface.c:280 #5 0x000000000040c75c in device_broadcast_cb (ctx=0x55c9, list=0x0) at /home/philipc/pkg/netifd/device.c:287 #6 0x00007ffff7bd660e in safe_list_for_each (head=head@entry=0x633850, cb=cb@entry=0x40c741 , ctx=ctx@entry=0x7fffffffe43c) at /home/philipc/pkg/libubox/safe_list.c:74 #7 0x000000000040c845 in device_broadcast_event (dev=dev@entry=0x633810, ev=ev@entry=DEV_EVENT_UP) at /home/philipc/pkg/netifd/device.c:296 #8 0x000000000040c8f0 in device_claim (dep=dep@entry=0x633270) at /home/philipc/pkg/netifd/device.c:315 #9 0x0000000000405ff2 in interface_set_up (iface=0x6331b0) at /home/philipc/pkg/netifd/interface.c:1009 #10 0x0000000000406de9 in interface_start_pending () at /home/philipc/pkg/netifd/interface.c:1040 #11 0x000000000040c6d8 in config_init_all () at /home/philipc/pkg/netifd/config.c:432 I can workaround the problem with the following patch. This doesn't seem like the correct way to fix this properly though: should we be calling device_claim() somewhere instead? iface->state = IFS_SETUP; — Reply to this email directly or view it on GitHub . diff --git a/interface.c b/interface.c index 848990e..b5a399d 100644 --- a/interface.c +++ b/interface.c @@ -275,6 +275,9 @@ __interface_set_up(struct interface *iface) { int ret; + if (iface->main_dev.dev && !iface->main_dev.claimed) + return -1; + netifd_log_message(L_NOTICE, "Interface '%s' is setting up now\n", iface->name);