From patchwork Mon May 18 12:37:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kovalev, Sergey" X-Patchwork-Id: 473365 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E02F814016A for ; Mon, 18 May 2015 22:38:04 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=emc.com header.i=@emc.com header.b=vUEL6z+5; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752012AbbERMiA (ORCPT ); Mon, 18 May 2015 08:38:00 -0400 Received: from mailuogwdur.emc.com ([128.221.224.79]:58830 "EHLO mailuogwdur.emc.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750949AbbERMh6 convert rfc822-to-8bit (ORCPT ); Mon, 18 May 2015 08:37:58 -0400 Received: from maildlpprd52.lss.emc.com (maildlpprd52.lss.emc.com [10.106.48.156]) by mailuogwprd54.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id t4ICbv01013234 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 18 May 2015 08:37:57 -0400 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd54.lss.emc.com t4ICbv01013234 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=emc.com; s=jan2013; t=1431952677; bh=bp60vP3o29LqlAbO8Rpc9Q225n0=; h=From:To:CC:Subject:Date:Message-ID:Content-Type: Content-Transfer-Encoding:MIME-Version; b=vUEL6z+5W7cHLyoDrf+2Sfg7yLhDvLJ1GA84JSj8KDlhlxsgD2NSj9lmqVAf4XJ+1 xKHCnCb5nMz/YI15J3cy3XhiyuISNyO+4ko4E3ciWCXPZ4kESl7mMKS8ahq81nHKh+ E8+vVnKYrcQkMyjpAVssFAZKT1MKO+vq6AVUjg3k= X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd54.lss.emc.com t4ICbv01013234 Received: from mailusrhubprd02.lss.emc.com (mailusrhubprd02.lss.emc.com [10.253.24.20]) by maildlpprd52.lss.emc.com (RSA Interceptor) for ; Mon, 18 May 2015 08:38:16 -0400 Received: from mxhub09.corp.emc.com (mxhub09.corp.emc.com [10.254.92.104]) by mailusrhubprd02.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id t4ICbl7B025988 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL) for ; Mon, 18 May 2015 08:37:47 -0400 Received: from MXHUB206.corp.emc.com (10.253.68.32) by mxhub09.corp.emc.com (10.254.92.104) with Microsoft SMTP Server (TLS) id 8.3.327.1; Mon, 18 May 2015 08:36:29 -0400 Received: from MX102CL01.corp.emc.com ([169.254.3.155]) by MXHUB206.corp.emc.com ([10.253.68.32]) with mapi id 14.03.0224.002; Mon, 18 May 2015 08:37:46 -0400 From: "Kovalev, Sergey" To: "netdev@vger.kernel.org" CC: "Dion, Christopher" , "Akopyan, Alexander" Subject: [PATCH] ping: ping doesn't work correctly with -m option Thread-Topic: [PATCH] ping: ping doesn't work correctly with -m option Thread-Index: AdCRZxefNe7chWYGSxmr28lxDFtjEw== Date: Mon, 18 May 2015 12:37:46 +0000 Message-ID: <7E20C7B36969D643A89BC9AE4BF0F3A422D31D95@MX102CL01.corp.emc.com> Accept-Language: ru-RU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.64.89.142] MIME-Version: 1.0 X-Sentrion-Hostname: mailusrhubprd02.lss.emc.com X-RSA-Classifications: Source Code, public Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The "ping" or "ping6" with parameter "-m" doesn't work when "main" and "default" table are empty (or do not have any route to destination IP). If we don't specify source IP address for the ping, the ping will try to determine the source IP automatically. To do so it creates the probe UDP socket, and try to connect to dst IP on that socket. The connect should make routing decision based on current Linux routing. If connection succeeded it takes source IP (however it doesn't use it in future indeed). The issue is that PIGN doesn't specify fwmark for that probe socket as a result connection fails with "Network unreachable" error. --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- ./ping.c.origin 2015-05-12 09:01:16.000000000 -0400 +++ ./ping.c 2015-05-13 07:34:06.000000000 -0400 @@ -107,6 +107,7 @@ struct sockaddr_in source; char *device; int pmtudisc = -1; +extern int mark; int @@ -305,6 +306,12 @@ } } } + if (options & F_MARK) { + if (setsockopt(probe_fd, SOL_SOCKET, SO_MARK, + &mark, sizeof(mark)) == -1) { + fprintf(stderr, "Warning: Failed to set mark %d\n", mark); + } + } if (settos && setsockopt(probe_fd, IPPROTO_IP, IP_TOS, (char *)&settos, sizeof(int)) < 0) --- ./ping6.c.origin 2015-05-12 09:01:16.000000000 -0400 +++ ./ping6.c 2015-05-13 07:33:39.000000000 -0400 @@ -137,7 +137,7 @@ int pmtudisc=-1; static int icmp_sock; - +extern int mark; static struct in6_addr in6_anyaddr; @@ -385,6 +385,12 @@ #endif } } + if (options & F_MARK) { + if (setsockopt(probe_fd, SOL_SOCKET, SO_MARK, + &mark, sizeof(mark)) == -1) { + fprintf(stderr, "Warning: Failed to set mark %d\n", mark); + } + } firsthop.sin6_port = htons(1025); if (connect(probe_fd, (struct sockaddr*)&firsthop, sizeof(firsthop)) == -1) { perror("connect");