Date: Wed, 10 Oct 2018 21:43:32 +0200 From: Andreas Kempe <kempe@lysator.liu.se> To: freebsd-net@freebsd.org Subject: Patching ng_iface to allow setting the MTU via netgraph API Message-ID: <33666112-c7e1-df6c-dfd5-22de0c1166fa@lysator.liu.se>
next in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --yE5ozS0Vc7X8eZKjvwDLggfQznPsL9KBR Content-Type: multipart/mixed; boundary="hUMniplebUrA71oaXe8LQFhm2PzB6dC1q"; protected-headers="v1" From: Andreas Kempe <kempe@lysator.liu.se> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?33666112-c7e1-df6c-dfd5-22de0c1166fa>