Re: [babel] Mandatory sub-TLVs in Next Hop and Router-ID
Toke Høiland-Jørgensen <toke@toke.dk> Wed, 24 May 2017 14:19 UTC
Return-Path: <toke@toke.dk>
X-Original-To: babel@ietfa.amsl.com
Delivered-To: babel@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id E68E7129508 for <babel@ietfa.amsl.com>; Wed, 24 May 2017 07:19:55 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.001
X-Spam-Level:
X-Spam-Status: No, score=-2.001 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=toke.dk
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xA_IYVYKsnGz for <babel@ietfa.amsl.com>; Wed, 24 May 2017 07:19:54 -0700 (PDT)
Received: from mail.toke.dk (mail.toke.dk [52.28.52.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id E2AF4128B88 for <babel@ietf.org>; Wed, 24 May 2017 07:19:53 -0700 (PDT)
From: Toke Høiland-Jørgensen <toke@toke.dk>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=toke.dk; s=20161023; t=1495635590; bh=fn2RnG+rAtIIVm1ZTjtCKICnhQxIsqh78guMh4fyevg=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=rKtAz2PM9IqMcucnpirDN1kEsYx8og7BYi2PaH5KHORJtQzCDpVcQdL0Z4QBXUooJ v3UUsJS/aYL8yIclNKpIS42lAf9D81FVKgubn7LdjW+/Y1XsDiHycUchR1XagE1TDO GrTxwu4XrNkNT4uZ0R4tfYhWpu6iEYOX1PPGJDJMn29IltT5ssjS5kIUcvoxOamUcY MseQV5qPKDAbdI4BmKhd+xSG6IE4zcDNOwyswRddRRO03Ii1gFO0wSMDdJ/x1s4dVZ TyG82/XARjuvGl+FCouoBODRgHo5CtEzpuCD52GQywpJFDMdo9MeB66k+tBwSIdCQN 9pN+AN72Fe1yQ==
To: Juliusz Chroboczek <jch@irif.fr>
Cc: babel@ietf.org
References: <87y3tmbg1e.wl-jch@irif.fr> <87zie2gylh.fsf@alrua-x1> <87h90abbp0.wl-jch@irif.fr> <87efvebb9x.wl-jch@irif.fr>
Date: Wed, 24 May 2017 16:19:50 +0200
In-Reply-To: <87efvebb9x.wl-jch@irif.fr> (Juliusz Chroboczek's message of "Wed, 24 May 2017 16:05:30 +0200")
X-Clacks-Overhead: GNU Terry Pratchett
Message-ID: <878tlmcp6h.fsf@alrua-kau>
MIME-Version: 1.0
Content-Type: text/plain
Archived-At: <https://mailarchive.ietf.org/arch/msg/babel/5g9TOYEukjDptaroF1Wf5fWIcFA>
Subject: Re: [babel] Mandatory sub-TLVs in Next Hop and Router-ID
X-BeenThere: babel@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: "A list for discussion of the Babel Routing Protocol." <babel.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/babel>, <mailto:babel-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/babel/>
List-Post: <mailto:babel@ietf.org>
List-Help: <mailto:babel-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/babel>, <mailto:babel-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 24 May 2017 14:19:56 -0000
Juliusz Chroboczek <jch@irif.fr> writes:
>> I suppose that if you're building a parse tree, then the two are roughly
>> similar.
>
> Hmm, I'm no longer so sure about that; it might actually be
> significantly simpler. Is that your case, Toke?
I'm not building a parse tree, I'm just doing two-pass parsing (first
pass reads wire data into an internal data structure while updating
parser state, second pass does protocol handling). The pseudo-code
example I posted before is not actually that far off from the actual C
function:
static inline int
babel_read_tlv(struct babel_tlv *hdr,
union babel_msg *msg,
struct babel_parse_state *state)
{
if ((hdr->type <= BABEL_TLV_PADN) ||
(hdr->type >= BABEL_TLV_MAX) ||
!tlv_data[hdr->type].read_tlv)
return PARSE_IGNORE;
if (TLV_LENGTH(hdr) < tlv_data[hdr->type].min_length)
return PARSE_ERROR;
memset(msg, 0, sizeof(*msg));
return tlv_data[hdr->type].read_tlv(hdr, msg, state);
}
What I was planning to do was just add a babel_read_subtlv() function
that would be called after the last line, which could just return
PARSE_IGNORE on unknown mandatory sub-TLVs (which would cause the
first-pass parser to drop the whole TLV).
I know this is very specific to the way I implemented things, but from
a high-level PoV, I'd agree with Markus that being consistent is better
than special-casing.
-Toke
- [babel] Mandatory sub-TLVs in Next Hop and Router… Juliusz Chroboczek
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Matthieu Boutier
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Juliusz Chroboczek
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Markus Stenberg
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Toke Høiland-Jørgensen
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Juliusz Chroboczek
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Juliusz Chroboczek
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Markus Stenberg
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Juliusz Chroboczek
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Toke Høiland-Jørgensen
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Juliusz Chroboczek
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Toke Høiland-Jørgensen
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Juliusz Chroboczek
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… David Schinazi
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Juliusz Chroboczek
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… David Schinazi
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Juliusz Chroboczek
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Juliusz Chroboczek
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Toke Høiland-Jørgensen
- Re: [babel] Mandatory sub-TLVs in Next Hop and Ro… Toke Høiland-Jørgensen