summaryrefslogtreecommitdiff
path: root/zebra/ioctl.c
AgeCommit message (Collapse)Author
2024-11-25zebra: Remove some unused functions on linux buildDonald Sharp
The functions: if_get_flags if_flags_update if_flags_mangle are never invoked from a linux netlink build. Put a #ifdef around those functions so that they are not included on the linux build as that they are not needed there. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04*: Remove sys/ioctl.h from zebra.hDonald Sharp
Practically no-one uses this and ioctls are pretty much wrappered. Further wrappering could make this even better. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-06-15zebra: Attempt to make ioctl.c have a bit more useful log messgesDonald Sharp
While examining the code, it was noticed that there was a chance to improve the log output in some cases to give a fuller understanding of what went wrong where. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-13zebra: Remove unused functions in netlink compilesDonald Sharp
When compiling with netlink, Remove the usage of these functions. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-11*: Properly use memset() when zeroingDonatas Abraitis
Wrong: memset(&a, 0, sizeof(struct ...)); Good: memset(&a, 0, sizeof(a)); Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-24zebra: Don't send uninited data to kernel on FreeBSDDonald Sharp
When running zebra w/ valgrind, it was noticed that there was a bunch of passing uninitialized data to the kernel: ==38194== Syscall param ioctl(generic) points to uninitialised byte(s) ==38194== at 0x4CDF88A: ioctl (in /lib/libc.so.7) ==38194== by 0x49A4031: vrf_ioctl (vrf.c:860) ==38194== by 0x2AFE29: vrf_if_ioctl (ioctl.c:91) ==38194== by 0x2AFF39: if_get_mtu (ioctl.c:161) ==38194== by 0x2B12C3: ifm_read (kernel_socket.c:653) ==38194== by 0x2A7F76: interface_list (if_sysctl.c:129) ==38194== by 0x2E9958: zebra_ns_enable (zebra_ns.c:127) ==38194== by 0x2E9958: zebra_ns_init (zebra_ns.c:214) ==38194== by 0x2B3F82: main (main.c:401) ==38194== Address 0x7fc000967 is on thread 1's stack ==38194== in frame #3, created by if_get_mtu (ioctl.c:155) ==38194== ==38194== Syscall param ioctl(generic) points to uninitialised byte(s) ==38194== at 0x4CDF88A: ioctl (in /lib/libc.so.7) ==38194== by 0x49A4031: vrf_ioctl (vrf.c:860) ==38194== by 0x2AFE29: vrf_if_ioctl (ioctl.c:91) ==38194== by 0x2AFED9: if_get_metric (ioctl.c:143) ==38194== by 0x2B12CB: ifm_read (kernel_socket.c:655) ==38194== by 0x2A7F76: interface_list (if_sysctl.c:129) ==38194== by 0x2E9958: zebra_ns_enable (zebra_ns.c:127) ==38194== by 0x2E9958: zebra_ns_init (zebra_ns.c:214) ==38194== by 0x2B3F82: main (main.c:401) ==38194== Address 0x7fc000967 is on thread 1's stack ==38194== in frame #3, created by if_get_metric (ioctl.c:137) ==38194== ==38194== Syscall param ioctl(generic) points to uninitialised byte(s) ==38194== at 0x4CDF88A: ioctl (in /lib/libc.so.7) ==38194== by 0x49A4031: vrf_ioctl (vrf.c:860) ==38194== by 0x2AFE29: vrf_if_ioctl (ioctl.c:91) ==38194== by 0x2B052D: if_get_flags (ioctl.c:419) ==38194== by 0x2B1CF1: ifam_read (kernel_socket.c:930) ==38194== by 0x2A7F57: interface_list (if_sysctl.c:132) ==38194== by 0x2E9958: zebra_ns_enable (zebra_ns.c:127) ==38194== by 0x2E9958: zebra_ns_init (zebra_ns.c:214) ==38194== by 0x2B3F82: main (main.c:401) ==38194== Address 0x7fc000707 is on thread 1's stack ==38194== in frame #3, created by if_get_flags (ioctl.c:411) Valgrind is no longer reporting these issues. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-09zebra: Keep the interface flags safe on multiple ioctl callsBijan
Trying to call multiple ioctl calls on ifreq will result in overwriting ifreq with garbage data. On if_get_flags call, try to keep the flags field safe from another possible ioctl call before applying the flags field. Modified code as per Code Review, done by Donald Sharp. Signed-off-by: Bijan <bijanebrahimi@riseup.net>
2021-11-22*: cleanup ifp->vrf_idIgor Ryzhov
Since f60a1188 we store a pointer to the VRF in the interface structure. There's no need anymore to store a separate vrf_id field. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-10-13zebra: ifi_link_state is the link stateRoy Marples
SIOCGIFMEDIA returns the media state. SIOCGIFDATA returns interface data which includes the link state. While the status of the former is usually indicitive of the latter, this is not always the case. Ifact some recent net80211 changes in at least NetBSD and OpenBSD have MONITOR media set to active but the link status set to DOWN. All interfaces will return link state with SIOCGIFDATA, unlike SIOCGIFMEDIA. However not all BSD's support SIOCGIFDATA - it has recently been accepted into FreeBSD-13. However, all BSD's do report the same structure in ifa_data for AF_LINK addresses from getifaddrs(3) so the information has always been available. Signed-off-by: Roy Marples <roy@marples.name>
2020-09-21*: Remove solaris from FRRDonald Sharp
The Solaris code has gone through a deprecation cycle. No-one has said anything to us and worse of all we don't have any test systems running Solaris to know if we are making changes that are breaking on Solaris. Remove it from the system so we can clean up a bit. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2019-09-03*: frr_elevate_privs -> frr_with_privsDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-23Revert "Ospf missing interface handling 2"Donald Sharp
2019-06-12*: change interface structure, from vrf_id to vrfPhilippe Guibert
Field vrf_id is replaced by the pointer of the struct vrf *. For that all other code referencing to (interface)->vrf_id is replaced. This work should not change the behaviour. It is just a continuation work toward having an interface API handling vrf pointer only. some new generic functions are created in vrf: vrf_to_id, vrf_to_name, a zebra function is also created: zvrf_info_lookup an ospf function is also created: ospf_lookup_by_vrf it is to be noted that now that interface has a vrf pointer, some more optimisations could be thought through all the rest of the code. as example, many structure store the vrf_id. those structures could get the exact vrf structure if inherited from an interface vrf context. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-29lib, zebra: remove uses of strncpyQuentin Young
This removes the last removable uses of strncpy in FRR. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-04-22zebra: removing old intf address codeMark Stapp
Remove old ioctl and netlink interface-address code after conversion to async dataplane Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-04-22zebra: Dplane interface address install for non-netlinkMark Stapp
ioctl-based platform code for interface address installation Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-04-22zebra: Use dplane for interface addresses (netlink)Mark Stapp
Start using the dataplane for interface-address programming, on netlink platforms. Other platforms just stubbed at this point. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-02-25zebra: remove all instances of strncpyQuentin Young
We have strlcpy. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-12-05zebra: don't log errors on unsupported mediasRafael Zalamena
When using `SIOCGIFMEDIA` check for `EINVAL`, otherwise we might print an error message on an unsupported interface. FreeBSD source code reference: https://github.com/freebsd/freebsd/blob/master/sys/net/if_media.c#L300 And: https://github.com/freebsd/freebsd/blob/8cb4b0c0181bd45318ee8977f77aea90c53bb224/usr.sbin/rtsold/if.c#L211 /* * EINVAL simply means that the interface does not support * the SIOCGIFMEDIA ioctl. We regard it alive. */ Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-09-13*: LIB_[ERR|WARN] -> EC_LIBQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06zebra: fix includesQuentin Young
Add and remove error related includes as necessary. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14*: use frr_elevate_privs() (1/2: coccinelle)David Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-14*: rename ferr_zlog -> flog_err_sysQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14*: rename zlog_fer -> flog_errQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14zebra, lib: error references for zebraQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14bgpd, lib, zebra: Convert LIB_ERR_PRIVILEGESDonald Sharp
For all the places we zlog_err about raising/lowering privileges, use zlog_ferr. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-27*: use C99 standard fixed-width integer typesQuentin Young
The following types are nonstandard: - u_char - u_short - u_int - u_long - u_int8_t - u_int16_t - u_int32_t Replace them with the C99 standard types: - uint8_t - unsigned short - unsigned int - unsigned long - uint8_t - uint16_t - uint32_t Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-06*: conform with COMMUNITY.md formatting rules, via 'make indent'Lou Berger
Signed-off-by: Lou Berger <lberger@labn.net>
2018-02-27zebra: handle some ioctl operations for VRFPhilippe Guibert
A new API is available for interface ioctl operations on Linux: vrf_if_ioctl. This is the unified API that permits doing ioctl operations on a per interface basis. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-12-13zebra: remove useless iotcl linux callsPhilippe Guibert
As netlink is available for all linux systems ( old linux distributions are not considered), this commit removes the ipv6 ioctl support for linux. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-12-13zebra: ipv6 addressing uses netlink socket instead of standard ioctlPhilippe Guibert
It is possible to configure IPv6 addresses from interfaces by using netlink socket, intead of using standard sockets. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-08-31Merge pull request #1044 from donaldsharp/combinationJafar Al-Gharaibeh
Coverity Cleanup of Stuff
2017-08-27zebra: configure PtP address on ifaliasreq systemsDavid Lamparter
support configuring a point-to-point address on systems using ioctl / struct ifaliasreq. error out when interface/address type mismatch. tested on FreeBSD 8.0-RELEASE. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-24*: fix assorted issues detected by Coverity ScanRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-07-31build: zebra: remove *_method Makefile hacksDavid Lamparter
replace with preprocessor checks in source files. Much simpler... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17*: reindentreindent-master-afterwhitespace / reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15*: make consistent & update GPLv2 file headersDavid Lamparter
The FSF's address changed, and we had a mixture of comment styles for the GPL file header. (The style with * at the beginning won out with 580 to 141 in existing files.) Note: I've intentionally left intact other "variations" of the copyright header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-08*: get rid of zlog(*, LOG_LEVEL, ...)David Lamparter
Result of running the following Coccinelle patch + fixups: <<EOF /* long-forms: zlog(NULL, <level>, ...) * => zlog_level(...) */ @@ expression list args; @@ - zlog(NULL, LOG_DEBUG, args) + zlog_debug(args) @@ expression list args; @@ - zlog(NULL, LOG_NOTICE, args) + zlog_notice(args) @@ expression list args; @@ - zlog(NULL, LOG_INFO, args) + zlog_info(args) @@ expression list args; @@ - zlog(NULL, LOG_WARNING, args) + zlog_warn(args) @@ expression list args; @@ - zlog(NULL, LOG_ERR, args) + zlog_err(args) /* long-forms: zlog(base->log, <level>, ...) * => zlog_level(...) */ @@ expression base; expression list args; @@ - zlog(base->log, LOG_DEBUG, args) + zlog_debug(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_NOTICE, args) + zlog_notice(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_INFO, args) + zlog_info(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_WARNING, args) + zlog_warn(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_ERR, args) + zlog_err(args) EOF Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-13frr: Remove HAVE_IPV6 from code baseDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-06all: removed all DEFUN command stomps (fix build errors)Daniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-06-08*: fix more initialisers (for BSD)David Lamparter
FreeBSD and NetBSD spew a few more warnings about variable initialisers. Found with OSR's/NetDEF's fancy new CI system. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-02-01lib, zebra: The Bulk of the conversion over to NS and VRFDonald Sharp
Convert the rest of zebra over to use a Namespae and VRF. Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2009-12-03zebra: fix argument reference in strncpy() call for BSDheasley
2008-07-01[zebra] Make BSD link-state deal more gracefully with GIFMEDIA ioctl errorPaul Jakma
2008-07-01 Paul Jakma <paul.jakma@sun.com> * ioctl.c: (if_get_flags) Deal more gracefully with failure of the BSD link-state SIOCGIFMEDIA ioctl, as some interfaces apparently don't implement it (e.g. tun). Also, make BSD link-state checking be conditional on the 'link-detect' interface configuration flag, as it should be. Fixes bug #465.
2008-02-26+ fix bug#326 by rib_lookup_and_pushup()Denis Ovsienko
2008-01-11[link-detect] Improve BSD support.Andrew J. Schorr
2008-01-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu> * lib/zebra.h: Revert previous change, no need to include <net/if_media.h> here. * zebra/ioctl.c: If HAVE_BSD_LINK_DETECT is defined, include <net/if_media.h> (if_get_flags) Remove debug messages about BSD link state. * zebra/kernel_socket.c: (bsd_linkdetect_translate) If link state is unknown, we should set the IFF_RUNNING flag.
2008-01-10[link-detect] Try to get BSD link-detect to work properly.Andrew J. Schorr
2008-01-10 Ingo Flaschberger <if@xip.at> * configure.ac: Define HAVE_BSD_LINK_DETECT if <net/if_media.h> is present. * lib/zebra.h: If HAVE_BSD_LINK_DETECT is defined, include <net/if_media.h>. * zebra/ioctl.c: (if_get_flags) If HAVE_BSD_LINK_DETECT, use the SIOCGIFMEDIA ioctl to ascertain link state. * zebra/kernel_socket.c: (bsd_linkdetect_translate) New function to map the ifm_data.ifi_link_state value into the IFF_RUNNING flag. (ifm_read) Call bsd_linkdetect_translate to fix the IFF_RUNNING flag before calling if_flags_update.
2007-05-10[autoconf] bugs 162,303,178: Fix 'present but can not be compiled' warningsPaul Jakma
2007-05-09 Paul Jakma <paul.jakma@sun.com> * configure.ac: sys/conf.h depends on sys/param.h, at least on FBSD 6.2. (bug #363) Should check for in_pktinfo for IRDP 2006-05-27 Paul Jakma <paul.jakma@sun.com> * configure.ac: General cleanup of header and type checks, introducing an internal define, QUAGGA_INCLUDES, to build up a list of stuff to include so as to avoid 'present but cant be compiled' warnings. Misc additional checks of things missing according to autoscan. Add LIBM, for bgpd's use of libm, so as to avoid burdening LIBS, and all the binaries, with libm linkage. Remove the bad practice of using m4 changequote(), just quote the []'s in the case statements properly. This should fix bugs 162, 303 and 178. * */*.{c,h}: Update all HAVE_* to the standard autoconf namespaced HAVE_* defines. I.e. HAVE_SA_LEN -> HAVE_STRUCT_SOCKADDR_SA_LEN, * bgpd/Makefile.am: Add LIBM to bgpd's LDADD, for pow().
2007-04-10[zebra] MTU change should propogate to zserv client on BSD/SolarisPaul Jakma
2007-04-10 Paul Jakma <paul.jakma@sun.com> * ioctl{_solaris,}.c: (if_get_mtu) Ping clients via zebra_interface_up_update if MTU is changed.