From owner-freebsd-net@freebsd.org Wed Oct 10 19:43:55 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 8FA9010BA52F for ; Wed, 10 Oct 2018 19:43:55 +0000 (UTC) (envelope-from kempe@lysator.liu.se) Received: from mail.lysator.liu.se (mail.lysator.liu.se [IPv6:2001:6b0:17:f0a0::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 167598F545 for ; Wed, 10 Oct 2018 19:43:54 +0000 (UTC) (envelope-from kempe@lysator.liu.se) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 7AD4440007 for ; Wed, 10 Oct 2018 21:43:45 +0200 (CEST) Received: by mail.lysator.liu.se (Postfix, from userid 1004) id 67F014001F; Wed, 10 Oct 2018 21:43:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on bernadotte.lysator.liu.se X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=ALL_TRUSTED,AWL autolearn=disabled version=3.4.1 X-Spam-Score: -0.7 Received: from drd1812.nothing.org (unknown [10.253.217.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 1316240007 for ; Wed, 10 Oct 2018 21:43:45 +0200 (CEST) To: freebsd-net@freebsd.org From: Andreas Kempe Subject: Patching ng_iface to allow setting the MTU via netgraph API Openpgp: preference=signencrypt Autocrypt: addr=kempe@lysator.liu.se; keydata= xsFNBFfcARkBEACpvItp92qIKstHBKcdfFFq7/Kd52IyQuOvLtJCn9Cvbipn48wxWBc2Ytzq OT0VueYpsX85VbJkCB8aTCVfm3xlHHozbttJ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hWRCAAoJEApKiq4XCkg94VsP/3pxr2cumMpqq8QFVwcsAvQQ YfzWnLfTty2f5djyNCUqp9voELqlJevUmKU7rp6aOHncNAws4RT23jQ+HWT/Hf4gafgFJJvn zarSt98jbFaeosFanxNX0lhk/vXaiMtrgjZ9Pa1tq8tNpfgQc1gLzrTVXWBBse9yIiEGxjM4 1Qm/1AgZk20ZO+7L1ykk/e7YKzIjttSlm8g1RkYDDCUnixZyyqFsYR1CU8MJVLTkIHVaVKGQ IO+Qmui6JFf/3voVl7Po3HbCi5ufWacAMYNAJtueb3bSMGkYiN0TCey9Ph4vXM4nHcf3QaPo nuQOysvrij2iyIdfFHmHH/Sx/esEX9Ynx5/HkM7ceQJtQjBxjPKNXXeoOKH1P3RhgE+d72QC ip2bGbGFS7r31wE3UbDaWgmARrSpTR10PWZCV4CxLVEppavXUkZjKw8ebCtQVEZEwPlAjhal /oUlagEw2m4ZGjl6EdtJxNZEhqWCpnzgNHiUzfPRGBnsu8d2ByAS3qv2t6RbiOgLhi1yInzc 80U8r3SMIJE++5ED5l81sm7csnNCDElf7QZK7n+9GEKvgoHgOrlBb0a0cu6z/IJ1o1R4LgfK cFAvGN+Ym4yuBMZEqUnLUF0n0OyMw4CvCMhh+II0YTsdqSOe5CI9LwxUqUIzPJJQw+7ahP7g qK9cqiHZL9a+ Message-ID: <33666112-c7e1-df6c-dfd5-22de0c1166fa@lysator.liu.se> Date: Wed, 10 Oct 2018 21:43:32 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="yE5ozS0Vc7X8eZKjvwDLggfQznPsL9KBR" X-Virus-Scanned: ClamAV using ClamSMTP 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: Wed, 10 Oct 2018 19:43:55 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --yE5ozS0Vc7X8eZKjvwDLggfQznPsL9KBR Content-Type: multipart/mixed; boundary="hUMniplebUrA71oaXe8LQFhm2PzB6dC1q"; protected-headers="v1" From: Andreas Kempe To: freebsd-net@freebsd.org Message-ID: <33666112-c7e1-df6c-dfd5-22de0c1166fa@lysator.liu.se> Subject: Patching ng_iface to allow setting the MTU via netgraph API --hUMniplebUrA71oaXe8LQFhm2PzB6dC1q Content-Type: multipart/mixed; boundary="------------69720751129D4A6DA8F4DB30" Content-Language: en-US This is a multi-part message in MIME format. --------------69720751129D4A6DA8F4DB30 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello! I am working on a meshnet concept and am using netgraph to put it right on top of the MAC layer. I am using ng_iface to do some tunneling of IP over my protocol and I thought it would be nice to be able to set the MTU of the created interface using the netgraph interface. I created a patch to do just that and thought I could share it if someone would find it worthwhile using for something, but I couldn't really figure out where to share it. I couldn't really get clarity from the contribution section in the handbook. If someone could point me in the right direction, it would be appreciated. I'll attach the patch to this mail as well since it is a quite small one. Cordially, Andreas Kempe --------------69720751129D4A6DA8F4DB30 Content-Type: text/x-patch; name="ng_iface_set_mtu.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ng_iface_set_mtu.patch" Index: share/man/man4/ng_iface.4 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- share/man/man4/ng_iface.4 (revision 338702) +++ share/man/man4/ng_iface.4 (arbetskopia) @@ -111,6 +111,8 @@ .It Dv NGM_IFACE_BROADCAST Pq Ic broadcast Set the interface to broadcast mode. The interface must not currently be up. +.It Dv NGM_IFACE_SET_MTU Pq Ic setmtu +Set the MTU of the interface. Given as a 16 bit unsigned integer. .El .Sh SHUTDOWN This node shuts down upon receipt of a Index: sys/netgraph/ng_iface.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sys/netgraph/ng_iface.c (revision 338702) +++ sys/netgraph/ng_iface.c (arbetskopia) @@ -181,6 +181,13 @@ NULL, &ng_parse_uint32_type }, + { + NGM_IFACE_COOKIE, + NGM_IFACE_SET_MTU, + "setmtu", + &ng_parse_uint16_type, + NULL + }, { 0 } }; =20 @@ -601,6 +608,7 @@ struct ng_mesg *resp =3D NULL; int error =3D 0; struct ng_mesg *msg; + struct ifreq ifr; =20 NGI_GET_MSG(item, msg); switch (msg->header.typecookie) { @@ -646,6 +654,13 @@ *((uint32_t *)resp->data) =3D priv->ifp->if_index; break; =20 + case NGM_IFACE_SET_MTU: + { + ifr.ifr_mtu =3D *((uint16_t *)msg->data); + error =3D ng_iface_ioctl(ifp, SIOCSIFMTU, (caddr_t) &ifr); + break; + } + default: error =3D EINVAL; break; Index: sys/netgraph/ng_iface.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sys/netgraph/ng_iface.h (revision 338702) +++ sys/netgraph/ng_iface.h (arbetskopia) @@ -68,6 +68,7 @@ NGM_IFACE_POINT2POINT, NGM_IFACE_BROADCAST, NGM_IFACE_GET_IFINDEX, + NGM_IFACE_SET_MTU, }; =20 #endif /* _NETGRAPH_NG_IFACE_H_ */ --------------69720751129D4A6DA8F4DB30-- --hUMniplebUrA71oaXe8LQFhm2PzB6dC1q-- --yE5ozS0Vc7X8eZKjvwDLggfQznPsL9KBR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEETci4cPcl+ZcyiACiCkqKrhcKSD0FAlu+VnAACgkQCkqKrhcK SD1jwA//evRUFmIfga6CPwb4yxUrcZoEqtRRmifilEysqNTBibtBo5kdBjA6xalL 7HqUWb3X2ECVcTgBzhPsNeqi4LIGeuMx4h7cHgNVKNfPoFdHfOS+IAHK4HYIj3HU yJmyHrak1nLhFRXHvXXx+WX/ONrzUz6THfBSaBmK25oDjiMIA7cRTXH6+C6y6dk6 3BbHscsGuzgFxIFg0LOE2cGr2pavyFacEBMCFuwPF2lCDAu0et4BArrkKz4BgLzF NbrEc+/A0yQsY5Bq82TpghmPJY241Px8Pj01FDo7Tsx4qjOOAMCUX8yP8cjjJ+yD Zj6s6CgJ6svmQyUOroLD8kg7u+CX9urnnNWG1Dhj37ljNysw1Wkxta3zZuqDnS4N teA609ENGFY2DmPTPJCoK4iS7n2blAmiHMCyVoU8WES1Es1p/0HSylBWlL/9NNjd 7nNTN09N+jGBpchCo3F+3o86HeuXX8Q3+JkUIMJ1OajXp7KajUU6ZcenF80ytJ/t mFycQmg4IuwbEApxQktlQDqrDR8UirAvoEpfOS2SbHRGk2sBUtGXnocv2bCrnVyD trZcI7/4ZOecwGHFvmUcKdRZ/zUSP6Wrog5Ex57YAIu2RHbVgeZdplmNwGamLt+N hvB3yUy1hQrwYyEqqU2u+r8dZzD0sv1nlQbLI+PLQ9Skfpqls2w= =QgAH -----END PGP SIGNATURE----- --yE5ozS0Vc7X8eZKjvwDLggfQznPsL9KBR--