Clearer naming of net functions

This commit is contained in:
Robert Swiecki 2016-03-03 15:43:40 +01:00
parent e02d4e4edf
commit 2c1ff531e3
4 changed files with 7 additions and 9 deletions

View File

@ -34,12 +34,10 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/mount.h>
#include <sys/personality.h> #include <sys/personality.h>
#include <sys/prctl.h> #include <sys/prctl.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
@ -51,7 +49,7 @@
bool containInitNetNs(struct nsjconf_t * nsjconf) bool containInitNetNs(struct nsjconf_t * nsjconf)
{ {
return netInitNs(nsjconf); return netInitNsFromChild(nsjconf);
} }
static bool containSetGroups(pid_t pid) static bool containSetGroups(pid_t pid)

6
net.c
View File

@ -48,7 +48,7 @@
#if defined(NSJAIL_NL3_WITH_MACVLAN) #if defined(NSJAIL_NL3_WITH_MACVLAN)
#include <netlink/route/link.h> #include <netlink/route/link.h>
#include <netlink/route/link/macvlan.h> #include <netlink/route/link/macvlan.h>
bool netCloneMacVtapAndNS(struct nsjconf_t * nsjconf, int pid) bool netInitNsFromParent(struct nsjconf_t * nsjconf, int pid)
{ {
if (nsjconf->iface == NULL) { if (nsjconf->iface == NULL) {
return true; return true;
@ -145,7 +145,7 @@ static bool netSystemSbinIp(struct nsjconf_t *nsjconf, char *const *argv)
} }
} }
bool netCloneMacVtapAndNS(struct nsjconf_t *nsjconf, int pid) bool netInitNsFromParent(struct nsjconf_t *nsjconf, int pid)
{ {
if (nsjconf->iface == NULL) { if (nsjconf->iface == NULL) {
return true; return true;
@ -429,7 +429,7 @@ static bool netConfigureVs(struct nsjconf_t *nsjconf)
return true; return true;
} }
bool netInitNs(struct nsjconf_t * nsjconf) bool netInitNsFromChild(struct nsjconf_t * nsjconf)
{ {
if (nsjconf->iface_no_lo == false) { if (nsjconf->iface_no_lo == false) {
if (netIfaceUp("lo") == false) { if (netIfaceUp("lo") == false) {

4
net.h
View File

@ -27,11 +27,11 @@
#include "common.h" #include "common.h"
bool netCloneMacVtapAndNS(struct nsjconf_t *nsjconf, int pid);
bool netLimitConns(struct nsjconf_t *nsjconf, int connsock); bool netLimitConns(struct nsjconf_t *nsjconf, int connsock);
int netGetRecvSocket(const char *bindhost, int port); int netGetRecvSocket(const char *bindhost, int port);
int netAcceptConn(int listenfd); int netAcceptConn(int listenfd);
void netConnToText(int fd, bool remote, char *buf, size_t s, struct sockaddr_in6 *addr_or_null); void netConnToText(int fd, bool remote, char *buf, size_t s, struct sockaddr_in6 *addr_or_null);
bool netInitNs(struct nsjconf_t *nsjconf); bool netInitNsFromParent(struct nsjconf_t *nsjconf, int pid);
bool netInitNsFromChild(struct nsjconf_t *nsjconf);
#endif /* _NET_H */ #endif /* _NET_H */

View File

@ -211,7 +211,7 @@ void subprocKillAll(struct nsjconf_t *nsjconf)
static bool subprocInitParent(struct nsjconf_t *nsjconf, pid_t pid, int pipefd) static bool subprocInitParent(struct nsjconf_t *nsjconf, pid_t pid, int pipefd)
{ {
if (netCloneMacVtapAndNS(nsjconf, pid) == false) { if (netInitNsFromParent(nsjconf, pid) == false) {
LOG_E("Couldn't create and put MACVTAP interface into NS of PID '%d'", pid); LOG_E("Couldn't create and put MACVTAP interface into NS of PID '%d'", pid);
return false; return false;
} }