summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/command.c2
-rw-r--r--lib/if.c2
-rw-r--r--lib/sockunion.c40
-rw-r--r--lib/sockunion.h2
4 files changed, 44 insertions, 2 deletions
diff --git a/lib/command.c b/lib/command.c
index 5a13f39c..264e0f7b 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -3056,7 +3056,7 @@ DEFUN (config_logmsg,
if ((level = level_match(argv[0])) == ZLOG_DISABLED)
return CMD_ERR_NO_MATCH;
- zlog(NULL, level, ((message = argv_concat(argv, argc, 1)) ? message : ""));
+ zlog(NULL, level, "%s", ((message = argv_concat(argv, argc, 1)) ? message : ""));
if (message)
XFREE(MTYPE_TMP, message);
return CMD_SUCCESS;
diff --git a/lib/if.c b/lib/if.c
index b61bdbff..86f754b6 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -664,7 +664,7 @@ connected_log (struct connected *connected, char *str)
strncat (logbuf, inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
BUFSIZ - strlen(logbuf));
}
- zlog (NULL, LOG_INFO, logbuf);
+ zlog (NULL, LOG_INFO, "%s", logbuf);
}
/* If two connected address has same prefix return 1. */
diff --git a/lib/sockunion.c b/lib/sockunion.c
index 6a40f332..a5382a72 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -527,6 +527,46 @@ sockopt_ttl (int family, int sock, int ttl)
return 0;
}
+int
+sockopt_cork (int sock, int onoff)
+{
+#ifdef TCP_CORK
+ return setsockopt (sock, IPPROTO_TCP, TCP_CORK, &onoff, sizeof(onoff));
+#else
+ return 0;
+#endif
+}
+
+int
+sockopt_minttl (int family, int sock, int minttl)
+{
+#ifdef IP_MINTTL
+ if (family == AF_INET)
+ {
+ int ret = setsockopt (sock, IPPROTO_IP, IP_MINTTL, &minttl, sizeof(minttl));
+ if (ret < 0)
+ zlog (NULL, LOG_WARNING,
+ "can't set sockopt IP_MINTTL to %d on socket %d: %s",
+ minttl, sock, safe_strerror (errno));
+ return ret;
+ }
+#endif /* IP_MINTTL */
+#ifdef IPV6_MINHOPCNT
+ if (family == AF_INET6)
+ {
+ int ret = setsockopt (sock, IPPROTO_IPV6, IPV6_MINHOPCNT, &minttl, sizeof(minttl));
+ if (ret < 0)
+ zlog (NULL, LOG_WARNING,
+ "can't set sockopt IPV6_MINHOPCNT to %d on socket %d: %s",
+ minttl, sock, safe_strerror (errno));
+ return ret;
+ }
+#endif
+
+ errno = EOPNOTSUPP;
+ return -1;
+}
+
/* If same family and same prefix return 1. */
int
sockunion_same (union sockunion *su1, union sockunion *su2)
diff --git a/lib/sockunion.h b/lib/sockunion.h
index 96b9a0d4..0ee2d63b 100644
--- a/lib/sockunion.h
+++ b/lib/sockunion.h
@@ -102,6 +102,8 @@ extern int sockopt_reuseport (int);
extern int sockunion_bind (int sock, union sockunion *,
unsigned short, union sockunion *);
extern int sockopt_ttl (int family, int sock, int ttl);
+extern int sockopt_minttl (int family, int sock, int minttl);
+extern int sockopt_cork (int sock, int onoff);
extern int sockunion_socket (union sockunion *su);
extern const char *inet_sutop (union sockunion *su, char *str);
extern enum connect_result sockunion_connect (int fd, union sockunion *su,