From owner-freebsd-net@freebsd.org Fri Aug 17 23:39:51 2018 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31D72107E9BB for ; Fri, 17 Aug 2018 23:39:51 +0000 (UTC) (envelope-from v.maffione@gmail.com) Received: from mail-qk0-x22c.google.com (mail-qk0-x22c.google.com [IPv6:2607:f8b0:400d:c09::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C1141775F9 for ; Fri, 17 Aug 2018 23:39:50 +0000 (UTC) (envelope-from v.maffione@gmail.com) Received: by mail-qk0-x22c.google.com with SMTP id b5-v6so7383877qkg.6 for ; Fri, 17 Aug 2018 16:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SfVtzsozKwBfwXfXyQ7vJCS7lKKriQhCu7oYqIEWIdk=; b=qKcAxqW53+uMez0ZSQrMH+yxkCRngI9RV4Du3PUanjrCbQ6jH9kg1mfdVc5Bwd9cv1 JGM91iZe+p9zyWZvdE6P56t6IoBosKp85ECGNLd+9SkzbLslGtMzj2TcgzqgC0MQrto3 7SwDu/TnzSWyDCn6ENfBB9f2TgHXcXTgUnmB1lR9EO1wbyUc1h4+tPAIwa0UG45pq921 LaxOGH2jM7bEya77mwh4afQ5insBG/o7uvP6eJ2Io+zz3MsYXW1jf2FlT6NE1OfDcIvE DCSX7tazqT5ZJFrcVmiQoBZrxJefhSEHHG+rb+HWrHBMBa93DS/NDbbR8MYC36yHy4Xi PB6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SfVtzsozKwBfwXfXyQ7vJCS7lKKriQhCu7oYqIEWIdk=; b=FOLj7lS1vNSqT3WurAwi3fcMX7SdgmeG19g6c2A+D5zwDEzLAaTr9Ri9NR2aWXoFu9 x+EcB+i2VFjv9RwBO51NxWa6M0SoMX9ucuTAKjZAD2PuyfNTvru2IuIfEt6gPZU9afL5 GOgfLkf9SnDHJiPOTdwny9CHt4PP4WR9ejtm65ds0J3kfgE1zYu+zcO6yUnX028mgt5h EUesN10ZxFML9xlCdMNplxJFPMH6MuC92pSX9uIsdfIVmfPSUu3fwZMxqrdTOYFk49Y6 aiCiKr8zR/UwoszAocINjWNc2AWtynFIfh/yx1BMbeOeM8NLvM1UxwPeW/CvQJb7gCcF LcTg== X-Gm-Message-State: AOUpUlGdSRA+KTNAwnozQMpOOpWp2fOUXpqaCu68zvkA7sV3d6jY0Wid d3gkatznAAzDtU5tXFo1CsN7E+fMHfRzpNnWANfuhUuR X-Google-Smtp-Source: AA+uWPw5Lf6QrpqGO9UD+AGI4SuJWMIkf2+b5OXwfSBBIuixmnsDCNvE4kCnLfJJDufuP1Tgp42YVgX4jrum4fqjr5Q= X-Received: by 2002:a37:b445:: with SMTP id d66-v6mr32734400qkf.357.1534549190095; Fri, 17 Aug 2018 16:39:50 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Vincenzo Maffione Date: Fri, 17 Aug 2018 18:39:39 -0500 Message-ID: Subject: Re: Getting netmap to co-exist with user-space processes that use sockets To: ipfix5101@gmail.com Cc: "freebsd-net@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2018 23:39:51 -0000 Hi, What you want to do is definitely possible using the "host rings", aka "sw rings". The idea is that netmap intercepts all the packets arriving from the NIC RX "hardware" ring(s). Your netmap program should then look at the packets and decide which ones should be forwarded to the host kernel (e.g. to sockets), and which ones are instead to be processed by your netmap program. All the packets to be forwarded to the host kernel can be transmitted to the "host TX ring". The host TX ring is a special ring that simply injects packets into the kernel. A similar thing happens for the egress side. Netmap intercepts all the packets that the host kernel tries to transmit on eth0. Those packets will show up in the "host RX ring", which is again a special ring. Your netmap program can then process those, for instance simply forwarding them to the hardware TX ring(s), so that they exit the eth0 interface. On a NIC with just 1 RX/TX hardware ring, you basically have 4 netmap rings. TX0 and RX0 are the hardware rings for transmission and reception. TX1 and RX1 are host rings, as explained above. I highly recommend to have a look at the netmap tutorial here https://github.com/netmap-unipi/netmap-tutorial Host rings are explained there. There is also a codelab with examples and solutions you can play with to learn the netmap API. >From the netmap API point of view, host rings are not different from hardware rings. Also having a look at the netmap man page can help. Remember to disable the NIC offloadings like checksumming and TSO or things won't work. Cheers, Vincenzo Il giorno ven 17 ago 2018 alle ore 11:33 VO Ipfix ha scritto: > Hello there, I would like to use netmap with pptk (emulated driver) to > generate send traffic from an interface, but still allow rx/tx to get to > the the kernel so that other user-space networking processes function as > normal. Currently, if I open an interface eg netmap:eth0, other user space > processes are unable to perform any networking via sockets. How could I go > about solving this? > > Thanks, > Victor > _______________________________________________ > freebsd-net@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" > -- Vincenzo