Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp255863pxf; Wed, 31 Mar 2021 02:34:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydr7bfun2IgVoYs13n51Uw4+cIIxdzDF6H4/SIDQTeGjomFDzzJNWmXwVXrDwZO5YOmQsM X-Received: by 2002:a17:906:16ca:: with SMTP id t10mr2600619ejd.85.1617183259040; Wed, 31 Mar 2021 02:34:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617183259; cv=none; d=google.com; s=arc-20160816; b=E55i7Uor0AV3ihN4qj6yH9kxurUat09z0HIH7YKyvRdfpT4z0L9go1ssKTVcKvWti+ aeDALGyRWD5gflE8vzAP4RvdGKsdzDO//Hlboiv4Tiw6rKggcmxR3U9B5bu3YnWOrCwf PRW9X8KuP78PfZ+ExwdppWjV84ABdOu55p1rNi+vXpRE/5y9/qzE0jCEIBudYoHBVWx6 uRfWt91PFF3iCC5jv6S5b7doqCamlLdX8C350JHrFelIIIM4SROGRxJCoHzYJYb3lAL5 Lc/vEX5B2Z0S6IFFT9vbav6Zwd0Lcx+iFJhG4Gcei21QRr7rf1pS/vKpBnGA5Sf5PnJp 8cTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ShH/N+LuitDskBEJpZBlqa67DkTm7tlQyc3A8jlCGS4=; b=mSIw/kxa5ehcmoeBZ374dS5mZr6rgVY9SGR3Cq43UASjj5zfTCjUyPX0LR1VY6rSyo g2RJ36NhXXVvaBF3lW8f9UtyE9buk/IeuNoS88o4o7SQD2+RRz0YQSt00TZ5Fstm8U+3 Bh3P3POh6xHxLjesnRr2RmbZrf+ZmzNNpMYuX5NBGEKwpu9gk6OeqGEPQpGc02SiZzpF JcNd6zUN3yOWPWo4hkOEHEWEikoUwaBBJ4zgv3JWhgjdloZkOMf2xnr2JaSuYHqqyGRt rD7bSrx0CguAZeP8G57/JcTwKwwfNWLTO/ZVrr9AWfVlUc9nOFUbSW3KYakMFkjVQGVR a5TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UtRNvJqc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k13si1385544edr.48.2021.03.31.02.33.55; Wed, 31 Mar 2021 02:34:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UtRNvJqc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232476AbhCaJcr (ORCPT + 99 others); Wed, 31 Mar 2021 05:32:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233912AbhCaJcd (ORCPT ); Wed, 31 Mar 2021 05:32:33 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21C8EC061574; Wed, 31 Mar 2021 02:32:33 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id h20so7607900plr.4; Wed, 31 Mar 2021 02:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=ShH/N+LuitDskBEJpZBlqa67DkTm7tlQyc3A8jlCGS4=; b=UtRNvJqcOt5ePiZVPOcbruviGUQSupiQWNq7jOFp+i0A/pXW9vKyMEk83Qy+U/Jp7j peH02WF8tp7zZLGCoQiVgElbOemKzfzlwbJJVhrOEqmcRzuXVYZq62iMGALv3jrTYUJ4 hwSbp0Ja/9J8tEf9XyI4dhz+OGF/R1YUvld7huQoo+uhBthMahkfAizHEaLbkabPtgZq X7z96OTaJudoLILxLWnOs+WHrkKXFylehpkbt+QxiGSxFEdr5LSIzggQjQSvPPGVepYe SSQ9H+i46PXpPTn+4Bk1u9Qd8o6lg8meAzoGKswxcGmvSErCrnT9gOrDSoCnRIs1SYc+ p8kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=ShH/N+LuitDskBEJpZBlqa67DkTm7tlQyc3A8jlCGS4=; b=p1MUQA7rBIKLn7gSIjb2+ZVY5clQ4d+VHRYO4snviVq26tZ4YFWufrI7PKb7Mv1jln a9E3zkBJGY2nMFi1x+4AsC/WdsWt8G16Wb++z0CLSzuAZsfFH5YvG+7KlNtPLJ8e7xi5 /pHmJR/06mB2oATUnfx/7yJA3veKfRTGDCQeAf+yBuhPt4fMjfZ7NtwXl8nE+zaDswmf 3wIRw8hAFyiIvRVIIQ32WEpN6XPBhISxomn4AojJNMp0dPUDPBRPv26PgJr9bw4HuQ0v 0no27FYy8G+keZHfKXfFwE9lmXZJjTL2hXgnMhFGx0M0SeLJnzVub1lxZnPYXQ02doFi EOAg== X-Gm-Message-State: AOAM533UKOg32knrScBOTIVcUrU/GcUcfclKbRH13xZHtiK15YBf/DfR X2ef05iUcQmnyxqnfyzxy7A= X-Received: by 2002:a17:90a:f314:: with SMTP id ca20mr2604192pjb.136.1617183152567; Wed, 31 Mar 2021 02:32:32 -0700 (PDT) Received: from localhost ([47.9.181.160]) by smtp.gmail.com with ESMTPSA id k13sm1647439pfc.50.2021.03.31.02.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 02:32:32 -0700 (PDT) Date: Wed, 31 Mar 2021 15:02:29 +0530 From: Kumar Kartikeya Dwivedi To: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= Cc: Andrii Nakryiko , bpf , Jesper Dangaard Brouer , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Shuah Khan , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , Peter Zijlstra , open list , Networking , "open list:KERNEL SELFTEST FRAMEWORK" Subject: Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API Message-ID: <20210331093026.hbxjbu43dnlm6mr4@apollo> References: <20210325120020.236504-1-memxor@gmail.com> <20210325120020.236504-4-memxor@gmail.com> <20210328080648.oorx2no2j6zslejk@apollo> <87czvgqrcj.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87czvgqrcj.fsf@toke.dk> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 31, 2021 at 02:41:40AM IST, Toke H?iland-J?rgensen wrote: > Andrii Nakryiko writes: > > > On Sun, Mar 28, 2021 at 1:11 AM Kumar Kartikeya Dwivedi > > wrote: > >> > >> On Sun, Mar 28, 2021 at 10:12:40AM IST, Andrii Nakryiko wrote: > >> > Is there some succinct but complete enough documentation/tutorial/etc > >> > that I can reasonably read to understand kernel APIs provided by TC > >> > (w.r.t. BPF, of course). I'm trying to wrap my head around this and > >> > whether API makes sense or not. Please share links, if you have some. > >> > > >> > >> Hi Andrii, > >> > >> Unfortunately for the kernel API part, I couldn't find any when I was working > >> on this. So I had to read the iproute2 tc code (tc_filter.c, f_bpf.c, > >> m_action.c, m_bpf.c) and the kernel side bits (cls_api.c, cls_bpf.c, act_api.c, > >> act_bpf.c) to grok anything I didn't understand. There's also similar code in > >> libnl (lib/route/{act,cls}.c). > >> > >> Other than that, these resources were useful (perhaps you already went through > >> some/all of them): > >> > >> https://docs.cilium.io/en/latest/bpf/#tc-traffic-control > >> https://qmonnet.github.io/whirl-offload/2020/04/11/tc-bpf-direct-action/ > >> tc(8), and tc-bpf(8) man pages > >> > >> I hope this is helpful! > > > > Thanks! I'll take a look. Sorry, I'm a bit behind with all the stuff, > > trying to catch up. > > > > I was just wondering if it would be more natural instead of having > > _dev _block variants and having to specify __u32 ifindex, __u32 > > parent_id, __u32 protocol, to have some struct specifying TC > > "destination"? Maybe not, but I thought I'd bring this up early. So > > you'd have just bpf_tc_cls_attach(), and you'd so something like > > > > bpf_tc_cls_attach(prog_fd, TC_DEV(ifindex, parent_id, protocol)) > > > > or > > > > bpf_tc_cls_attach(prog_fd, TC_BLOCK(block_idx, protocol)) > > > > ? Or it's taking it too far? > > Hmm, that's not a bad idea, actually. An earlier version of the series > did have only a single set of functions, but with way too many > arguments, which is why we ended up agreeing to split them. But > encapsulating the destination in a separate struct and combining it with > some helper macros might just make this work! I like it! Kumar, WDYT? > SGTM. > -Toke > -- Kartikeya