diff options
-rw-r--r-- | bgpd/bgp_network.c | 14 | ||||
-rw-r--r-- | lib/log.c | 4 | ||||
-rw-r--r-- | lib/log.h | 2 | ||||
-rw-r--r-- | lib/memory.c | 2 | ||||
-rw-r--r-- | lib/sockopt.c | 13 | ||||
-rw-r--r-- | lib/sockopt.h | 1 | ||||
-rw-r--r-- | ospfd/ospf_network.c | 11 | ||||
-rw-r--r-- | ripd/ripd.c | 5 | ||||
-rw-r--r-- | zebra/kernel_socket.c | 2 | ||||
-rw-r--r-- | zebra/kernel_socket.h | 2 | ||||
-rw-r--r-- | zebra/rt_netlink.c | 4 |
11 files changed, 41 insertions, 19 deletions
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 71f3ec7d..5dbd4872 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -314,6 +314,11 @@ bgp_connect (struct peer *peer) sockopt_reuseaddr (peer->fd); sockopt_reuseport (peer->fd); +#ifdef IPTOS_PREC_INTERNETCONTROL + if (sockunion_family (&peer->su) == AF_INET) + setsockopt_ipv4_tos (peer->fd, IPTOS_PREC_INTERNETCONTROL); +#endif + if (peer->password) bgp_md5_set_connect (peer->fd, &peer->su, peer->password); @@ -402,6 +407,11 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address) sockopt_reuseaddr (sock); sockopt_reuseport (sock); +#ifdef IPTOS_PREC_INTERNETCONTROL + if (ainfo->ai_family == AF_INET) + setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL); +#endif + if (bgpd_privs.change (ZPRIVS_RAISE) ) zlog_err ("bgp_socket: could not raise privs"); @@ -454,6 +464,10 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address) sockopt_reuseaddr (sock); sockopt_reuseport (sock); +#ifdef IPTOS_PREC_INTERNETCONTROL + setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL); +#endif + memset (&sin, 0, sizeof (struct sockaddr_in)); sin.sin_family = AF_INET; @@ -740,9 +740,9 @@ zlog_rotate (struct zlog *zl) /* Message lookup function. */ const char * -lookup (struct message *mes, int key) +lookup (const struct message *mes, int key) { - struct message *pnt; + const struct message *pnt; for (pnt = mes; pnt->key != 0; pnt++) if (pnt->key == key) @@ -144,7 +144,7 @@ extern int zlog_rotate (struct zlog *); /* For hackey massage lookup and check */ #define LOOKUP(x, y) mes_lookup(x, x ## _max, y, "(no item found)") -extern const char *lookup (struct message *, int); +extern const char *lookup (const struct message *, int); extern const char *mes_lookup (struct message *meslist, int max, int index, const char *no_item); diff --git a/lib/memory.c b/lib/memory.c index 9ed5e100..28b3d896 100644 --- a/lib/memory.c +++ b/lib/memory.c @@ -33,7 +33,7 @@ static void alloc_inc (int); static void alloc_dec (int); static void log_memstats(int log_priority); -static struct message mstr [] = +static const struct message mstr [] = { { MTYPE_THREAD, "thread" }, { MTYPE_THREAD_MASTER, "thread_master" }, diff --git a/lib/sockopt.c b/lib/sockopt.c index a2038a5c..2f01199a 100644 --- a/lib/sockopt.c +++ b/lib/sockopt.c @@ -343,6 +343,19 @@ setsockopt_ipv4_ifindex (int sock, int val) } int +setsockopt_ipv4_tos(int sock, int tos) +{ + int ret; + + ret = setsockopt (sock, IPPROTO_IP, IP_TOS, &tos, sizeof (tos)); + if (ret < 0) + zlog_warn ("Can't set IP_TOS option for fd %d to %#x: %s", + sock, tos, safe_strerror(errno)); + return ret; +} + + +int setsockopt_ifindex (int af, int sock, int val) { int ret = -1; diff --git a/lib/sockopt.h b/lib/sockopt.h index 95382792..cb05c6fb 100644 --- a/lib/sockopt.h +++ b/lib/sockopt.h @@ -89,6 +89,7 @@ extern int setsockopt_multicast_ipv4(int sock, int optname, unsigned int ifindex /* optional: if non-zero, may be used instead of if_addr */); +extern int setsockopt_ipv4_tos(int sock, int tos); /* Ask for, and get, ifindex, by whatever method is supported. */ extern int setsockopt_ifindex (int, int, int); diff --git a/ospfd/ospf_network.c b/ospfd/ospf_network.c index d5bf7493..89ff2038 100644 --- a/ospfd/ospf_network.c +++ b/ospfd/ospf_network.c @@ -165,11 +165,7 @@ int ospf_sock_init (void) { int ospf_sock; - /* - * XXX warning: unused variable `tos' - * tos should be ifdefed similarly to usage - */ - int ret, tos, hincl = 1; + int ret, hincl = 1; if ( ospfd_privs.change (ZPRIVS_RAISE) ) zlog_err ("ospf_sock_init: could not raise privs, %s", @@ -201,10 +197,7 @@ ospf_sock_init (void) #elif defined (IPTOS_PREC_INTERNETCONTROL) #warning "IP_HDRINCL not available on this system" #warning "using IPTOS_PREC_INTERNETCONTROL" - /* Set precedence field. */ - tos = IPTOS_PREC_INTERNETCONTROL; - ret = setsockopt (ospf_sock, IPPROTO_IP, IP_TOS, - (char *) &tos, sizeof (int)); + ret = setsockopt_ipv4_tos(ospf_sock, IPTOS_PREC_INTERNETCONTROL); if (ret < 0) { int save_errno = errno; diff --git a/ripd/ripd.c b/ripd/ripd.c index 62d8691c..2525679c 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -76,7 +76,7 @@ enum }; /* RIP command strings. */ -struct message rip_msg[] = +static const struct message rip_msg[] = { {RIP_REQUEST, "REQUEST"}, {RIP_RESPONSE, "RESPONSE"}, @@ -84,6 +84,7 @@ struct message rip_msg[] = {RIP_TRACEOFF, "TRACEOFF"}, {RIP_POLL, "POLL"}, {RIP_POLL_ENTRY, "POLL ENTRY"}, + {0, NULL}, }; /* Utility function to set boradcast option to the socket. */ @@ -3508,7 +3509,7 @@ DEFUN (show_ip_rip_status, struct listnode *node; struct interface *ifp; struct rip_interface *ri; - extern struct message ri_version_msg[]; + extern const struct message ri_version_msg[]; const char *send_version; const char *receive_version; diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 2e04b031..e77b9b78 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -126,7 +126,7 @@ extern struct zebra_t zebrad; (LEN) = 0; \ } /* Routing socket message types. */ -struct message rtm_type_str[] = +const struct message rtm_type_str[] = { {RTM_ADD, "RTM_ADD"}, {RTM_DELETE, "RTM_DELETE"}, diff --git a/zebra/kernel_socket.h b/zebra/kernel_socket.h index 8f8a2075..e9558ad6 100644 --- a/zebra/kernel_socket.h +++ b/zebra/kernel_socket.h @@ -28,6 +28,6 @@ extern int ifam_read (struct ifa_msghdr *); extern int ifm_read (struct if_msghdr *); extern int rtm_write (int, union sockunion *, union sockunion *, union sockunion *, unsigned int, int, int); -extern struct message rtm_type_str[]; +extern const struct message rtm_type_str[]; #endif /* __ZEBRA_KERNEL_SOCKET_H */ diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 0a6b8dde..395f1ca6 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -52,7 +52,7 @@ struct nlsock } netlink = { -1, 0, {0}, "netlink-listen"}, /* kernel messages */ netlink_cmd = { -1, 0, {0}, "netlink-cmd"}; /* command channel */ -static struct message nlmsg_str[] = { +static const struct message nlmsg_str[] = { {RTM_NEWROUTE, "RTM_NEWROUTE"}, {RTM_DELROUTE, "RTM_DELROUTE"}, {RTM_GETROUTE, "RTM_GETROUTE"}, @@ -805,7 +805,7 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h) return 0; } -struct message rtproto_str[] = { +static const struct message rtproto_str[] = { {RTPROT_REDIRECT, "redirect"}, {RTPROT_KERNEL, "kernel"}, {RTPROT_BOOT, "boot"}, |