diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sockunion.c | 19 | ||||
| -rw-r--r-- | lib/sockunion.h | 3 |
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/sockunion.c b/lib/sockunion.c index efd41362c6..59c5ba5dd0 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -496,6 +496,25 @@ sockopt_cork (int sock, int onoff) #endif } +int sockopt_mark_default(int sock, int mark, struct zebra_privs_t *cap) +{ +#ifdef SO_MARK + int ret; + + if ( cap->change (ZPRIVS_RAISE) ) + zlog_err ("routing_socket: Can't raise privileges"); + + ret = setsockopt(sock, SOL_SOCKET, SO_MARK, &mark, sizeof(mark)); + + if ( cap->change (ZPRIVS_LOWER) ) + zlog_err ("routing_socket: Can't lower privileges"); + + return ret; +#else + return 0; +#endif +} + int sockopt_minttl (int family, int sock, int minttl) { diff --git a/lib/sockunion.h b/lib/sockunion.h index 8f0a9be37c..78356e4cb7 100644 --- a/lib/sockunion.h +++ b/lib/sockunion.h @@ -23,6 +23,8 @@ #ifndef _ZEBRA_SOCKUNION_H #define _ZEBRA_SOCKUNION_H +#include "privs.h" + #if 0 union sockunion { struct sockinet { @@ -99,6 +101,7 @@ extern int sockunion_bind (int sock, 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 sockopt_mark_default(int sock, int mark, struct zebra_privs_t *); 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, |
