*/
/*
- * Thanks to Jens Låås at Swedish University of Agricultural Sciences
+ * Thanks to Jens Laas at Swedish University of Agricultural Sciences
* for reviewing and tests.
*/
#include "thread.h"
#include "privs.h"
#include "libfrr.h"
+#include "lib_errors.h"
#include "version.h"
#include "zebra/interface.h"
#include "zebra/rtadv.h"
#include "zebra/zserv.h"
#include "zebra/redistribute.h"
#include "zebra/irdp.h"
+#include "zebra/zebra_errors.h"
#include <netinet/ip_icmp.h>
#include "checksum.h"
int save_errno;
int sock;
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog_err("irdp_sock_init: could not raise privs, %s",
- safe_strerror(errno));
+ frr_elevate_privs(&zserv_privs) {
- sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
- save_errno = errno;
+ sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
+ save_errno = errno;
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog_err("irdp_sock_init: could not lower privs, %s",
- safe_strerror(errno));
+ }
if (sock < 0) {
- zlog_warn("IRDP: can't create irdp socket %s",
- safe_strerror(save_errno));
+ flog_err_sys(EC_LIB_SOCKET, "IRDP: can't create irdp socket %s",
+ safe_strerror(save_errno));
return sock;
};
i = 1;
ret = setsockopt(sock, IPPROTO_IP, IP_TTL, (void *)&i, sizeof(i));
if (ret < 0) {
- zlog_warn("IRDP: can't do irdp sockopt %s",
- safe_strerror(errno));
+ flog_err_sys(EC_LIB_SOCKET, "IRDP: can't do irdp sockopt %s",
+ safe_strerror(errno));
close(sock);
return ret;
};
ret = setsockopt_ifindex(AF_INET, sock, 1);
if (ret < 0) {
- zlog_warn("IRDP: can't do irdp sockopt %s",
- safe_strerror(errno));
+ flog_err_sys(EC_LIB_SOCKET, "IRDP: can't do irdp sockopt %s",
+ safe_strerror(errno));
close(sock);
return ret;
};
struct irdp_interface *irdp = zi->irdp;
int size;
int pref;
- u_int16_t checksum;
+ uint16_t checksum;
pref = get_pref(irdp, p);
struct zebra_if *zi = ifp->info;
struct irdp_interface *irdp = zi->irdp;
char buf[PREFIX_STRLEN];
- u_int32_t dst;
- u_int32_t ttl = 1;
+ uint32_t dst;
+ uint32_t ttl = 1;
if (!irdp)
return;
int irdp_send_thread(struct thread *t_advert)
{
- u_int32_t timer, tmp;
+ uint32_t timer, tmp;
struct interface *ifp = THREAD_ARG(t_advert);
struct zebra_if *zi = ifp->info;
struct irdp_interface *irdp = zi->irdp;
{
struct zebra_if *zi = ifp->info;
struct irdp_interface *irdp = zi->irdp;
- u_int32_t timer;
+ uint32_t timer;
if (!irdp)
return;
return 0;
}
-FRR_MODULE_SETUP(
- .name = "zebra_irdp",
- .version = FRR_VERSION,
- .description = "zebra IRDP module",
- .init = irdp_module_init,
-)
+FRR_MODULE_SETUP(.name = "zebra_irdp", .version = FRR_VERSION,
+ .description = "zebra IRDP module", .init = irdp_module_init, )