From patchwork Mon Mar 30 18:15:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Shearman X-Patchwork-Id: 456278 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 4A1441400DE for ; Tue, 31 Mar 2015 05:17:51 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753343AbbC3SRr (ORCPT ); Mon, 30 Mar 2015 14:17:47 -0400 Received: from mx0b-000f0801.pphosted.com ([67.231.152.113]:8131 "EHLO mx0b-000f0801.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753315AbbC3SRp (ORCPT ); Mon, 30 Mar 2015 14:17:45 -0400 Received: from pps.filterd (m0048192.ppops.net [127.0.0.1]) by mx0b-000f0801.pphosted.com (8.14.7/8.14.7) with SMTP id t2UHpBaU027027; Mon, 30 Mar 2015 11:17:43 -0700 Received: from brmwp-exchub02.corp.brocade.com ([208.47.132.227]) by mx0b-000f0801.pphosted.com with ESMTP id 1tdg5jnqv5-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Mon, 30 Mar 2015 11:17:43 -0700 Received: from EMEAWP-CASH01.corp.brocade.com (172.29.18.10) by BRMWP-EXCHUB02.corp.brocade.com (172.16.187.99) with Microsoft SMTP Server (TLS) id 14.3.123.3; Mon, 30 Mar 2015 12:17:42 -0600 Received: from BRA-2XN4P12.brocade.com (10.72.40.2) by imapeu.brocade.com (172.29.18.15) with Microsoft SMTP Server (TLS) id 8.3.298.1; Mon, 30 Mar 2015 20:17:39 +0200 From: Robert Shearman To: CC: , Robert Shearman , "Eric W. Biederman" Subject: [PATCH net-next v3 2/4] mpls: Differentiate implicit-null and unlabeled neighbours Date: Mon, 30 Mar 2015 19:15:54 +0100 Message-ID: <1427739356-28113-3-git-send-email-rshearma@brocade.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427739356-28113-1-git-send-email-rshearma@brocade.com> References: <1426866170-28739-1-git-send-email-rshearma@brocade.com> <1427739356-28113-1-git-send-email-rshearma@brocade.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.13.68, 1.0.33, 0.0.0000 definitions=2015-03-30_04:2015-03-30, 2015-03-30, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=1 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1503300169 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The control plane can advertise labels for neighbours that don't have an outgoing label. RFC 3031 s3.22 states that either the remaining labels should be popped (if the control plane can determine that it's safe to do so, which in light of MPLS-VPN, RFC 4364, is never the case now) or that the packet should be discarded. Therefore, if the peer is unlabeled and the last label wasn't popped then drop the packet. The peer being unlabeled is signalled by an empty label stack. However, penultimate hop popping still needs to be supported (RFC 3031 s4.1.5) where the incoming label is popped and no labels are put on and the packet can still go out labeled with the remainder of the stack. This is achieved by the control plane specifying a label stack consisting of the single special implicit-null value. Cc: "Eric W. Biederman" Signed-off-by: Robert Shearman --- net/mpls/af_mpls.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c index 0d6763a895d6..7f5f30d29f73 100644 --- a/net/mpls/af_mpls.c +++ b/net/mpls/af_mpls.c @@ -28,7 +28,8 @@ struct mpls_route { /* next hop label forwarding entry */ struct rcu_head rt_rcu; u32 rt_label[MAX_NEW_LABELS]; u8 rt_protocol; /* routing protocol that set this entry */ - u8 rt_labels; + u8 rt_unlabeled : 1; + u8 rt_labels : 7; u8 rt_via_alen; u8 rt_via_table; u8 rt_via[0]; @@ -202,6 +203,11 @@ static int mpls_forward(struct sk_buff *skb, struct net_device *dev, /* Penultimate hop popping */ if (!mpls_egress(rt, skb, dec)) goto drop; + } else if (rt->rt_unlabeled) { + /* Labeled traffic destined to unlabeled peer should + * be discarded + */ + goto drop; } else { bool bos; int i; @@ -386,9 +392,16 @@ static int mpls_route_add(struct mpls_route_config *cfg) if (!rt) goto errout; - rt->rt_labels = cfg->rc_output_labels; - for (i = 0; i < rt->rt_labels; i++) - rt->rt_label[i] = cfg->rc_output_label[i]; + if (cfg->rc_output_labels == 1 && + cfg->rc_output_label[0] == LABEL_IMPLICIT_NULL) { + rt->rt_labels = 0; + } else { + rt->rt_labels = cfg->rc_output_labels; + for (i = 0; i < rt->rt_labels; i++) + rt->rt_label[i] = cfg->rc_output_label[i]; + if (!rt->rt_labels) + rt->rt_unlabeled = true; + } rt->rt_protocol = cfg->rc_protocol; RCU_INIT_POINTER(rt->rt_dev, dev); rt->rt_via_table = cfg->rc_via_table;