リビジョン | ff7dbac45c2341fade032200cc5e5cdc5971b9ba (tree) |
---|---|
日時 | 2014-07-11 17:19:45 |
作者 | Hiroaki Nakano <nakano.hiroaki@nttc...> |
コミッター | Hiroaki Nakano |
edit途中。
- l7vs_service_argにある使わないchild_pid配列のせいでl7vsadmが失敗していたので削除
- 親プロセスと子プロセスの間でやり取りするipとportがネットバイトオーダーだったので、通常のものに変換。それに伴うIF変更対応。
Signed-off-by: Hiroaki Nakano <nakano.hiroaki@nttcom.co.jp>
@@ -89,8 +89,6 @@ struct l7vs_service_arg{ | ||
89 | 89 | int persist; //! persistency |
90 | 90 | int backlog; //! listen(2) backlog length |
91 | 91 | |
92 | - pid_t child_pid[MAX_CHILD]; //! child process pid list | |
93 | - | |
94 | 92 | char protomod[L7VS_MODNAME_LEN]; //! protocol module name |
95 | 93 | char schedmod[L7VS_MODNAME_LEN]; //! scheduler |
96 | 94 |
@@ -841,7 +841,7 @@ l7vs_child_proto_grp_init(uint32_t ip, uint16_t port, char *proto) | ||
841 | 841 | * @return l7vs_child_proto_grp pointer |
842 | 842 | */ |
843 | 843 | struct l7vs_child_proto_grp * |
844 | -l7vs_child_proto_grp_search(uint32_t ip, uint16_t port) | |
844 | +l7vs_child_proto_grp_search(struct in_addr ip, uint16_t port) | |
845 | 845 | { |
846 | 846 | GList *l; |
847 | 847 | struct l7vs_child_proto_grp *grp; |
@@ -849,7 +849,7 @@ l7vs_child_proto_grp_search(uint32_t ip, uint16_t port) | ||
849 | 849 | grp = NULL; |
850 | 850 | for(l = g_list_first(l7vs_child_list); l != NULL; l = g_list_next(l)) { |
851 | 851 | grp = (struct l7vs_child_proto_grp *)l->data; |
852 | - if((grp->addr.sin_addr.s_addr != ip) || (grp->addr.sin_port != port)) { | |
852 | + if((grp->addr.sin_addr.s_addr != ip.s_addr) || (grp->addr.sin_port != port)) { | |
853 | 853 | continue; |
854 | 854 | }else{ |
855 | 855 | return grp; |
@@ -983,7 +983,7 @@ l7vs_child_process_check(struct l7vs_service_arg_multi *arg) | ||
983 | 983 | struct l7vs_child_proto_grp *cpgrp; |
984 | 984 | |
985 | 985 | /* IP, port重複チェック */ |
986 | - cpgrp = l7vs_child_proto_grp_search(arg->srv_arg.addr.sin_addr.s_addr,arg->srv_arg.addr.sin_port); | |
986 | + cpgrp = l7vs_child_proto_grp_search(arg->srv_arg.addr.sin_addr, arg->srv_arg.addr.sin_port); | |
987 | 987 | if(cpgrp == NULL){ |
988 | 988 | /* 無かったので子プロ作る */ |
989 | 989 | srv_sock_check_flg = 0; |
@@ -1121,7 +1121,7 @@ l7vs_service_create(struct l7vs_service_arg_multi *arg, int *err) | ||
1121 | 1121 | int srv_mod_check_flg = 0; |
1122 | 1122 | int ret = 0; |
1123 | 1123 | int i, readid, writeid, writefifo, readfifo, dummyfifo; |
1124 | - uint32_t ip; | |
1124 | + char *ip; | |
1125 | 1125 | uint16_t port; |
1126 | 1126 | pid_t pid; |
1127 | 1127 | GList *l; |
@@ -1182,11 +1182,11 @@ l7vs_service_create(struct l7vs_service_arg_multi *arg, int *err) | ||
1182 | 1182 | if( srv == NULL) return NULL; |
1183 | 1183 | |
1184 | 1184 | /* 名前付きパイプ作成 */ |
1185 | - ip = arg->srv_arg.addr.sin_addr.s_addr; | |
1186 | - port = arg->srv_arg.addr.sin_port; | |
1185 | + ip = inet_ntoa(arg->srv_arg.addr.sin_addr); | |
1186 | + port = ntohs(arg->srv_arg.addr.sin_port); | |
1187 | 1187 | pid = getpid(); |
1188 | 1188 | |
1189 | - snprintf(fifopath, sizeof(fifopath), "/tmp/l7vsd_%ud_%ud", ip, port); | |
1189 | + snprintf(fifopath, sizeof(fifopath), "/tmp/l7vsd_%s_%d", ip, port); | |
1190 | 1190 | ret = stat(fifopath, &st); |
1191 | 1191 | if(!ret){ |
1192 | 1192 | if(!(S_ISDIR(st.st_mode))){ |
@@ -1210,7 +1210,7 @@ l7vs_service_create(struct l7vs_service_arg_multi *arg, int *err) | ||
1210 | 1210 | } |
1211 | 1211 | } |
1212 | 1212 | |
1213 | - snprintf(fifoname, sizeof(fifoname), "/tmp/l7vsd_%ud_%ud/l7vsd.%ud", ip, port, pid); | |
1213 | + snprintf(fifoname, sizeof(fifoname), "/tmp/l7vsd_%s_%d/l7vsd.%d", ip, port, pid); | |
1214 | 1214 | ret = mkfifo(fifoname, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); |
1215 | 1215 | if(ret == -1){ |
1216 | 1216 | perror("mkfifo"); |
@@ -1233,7 +1233,7 @@ l7vs_service_create(struct l7vs_service_arg_multi *arg, int *err) | ||
1233 | 1233 | l7vs_iomux_add( l7vs_cfifo_iomux, iom_read ); |
1234 | 1234 | |
1235 | 1235 | /* 親PIPEを開いてPIDとIP,portを親に通知 */ |
1236 | - snprintf(childinfo, sizeof(childinfo), "%ud %ud %ud", ip, port, pid); | |
1236 | + snprintf(childinfo, sizeof(childinfo), "%s %d %d", ip, port, pid); | |
1237 | 1237 | if((writefifo = open(P_FIFO, O_WRONLY, 0)) < 0) { |
1238 | 1238 | perror("open"); |
1239 | 1239 | /* 各種アンロード */ |
@@ -1285,10 +1285,12 @@ int | ||
1285 | 1285 | l7vs_receive_child_process_info(int fd) |
1286 | 1286 | { |
1287 | 1287 | // すぐ上のforkの親プロセス処理でやるか、epollイベントでやるか検討 |
1288 | - uint32_t ip; | |
1289 | - uint16_t port; | |
1288 | + char ip[17]; | |
1289 | + struct in_addr nip; | |
1290 | + uint16_t port, nport; | |
1290 | 1291 | pid_t pid; |
1291 | 1292 | struct l7vs_child_proto_grp *grp; |
1293 | + int ret; | |
1292 | 1294 | |
1293 | 1295 | // 読み込み |
1294 | 1296 | if((read(fd, childinfo, sizeof(childinfo)))==-1) { |
@@ -1297,9 +1299,15 @@ l7vs_receive_child_process_info(int fd) | ||
1297 | 1299 | } |
1298 | 1300 | |
1299 | 1301 | // ip, port, pidを切り出す |
1300 | - sscanf(childinfo, "%ud %ud %ud", ip, port, pid); | |
1302 | + sscanf(childinfo, "%s %d %d", ip, port, pid); | |
1303 | + // 取り出した情報をネットワークバイトオーダーに変換する | |
1304 | + if(!(inet_aton(ip, &nip))){ | |
1305 | + return -1; | |
1306 | + } | |
1307 | + nport = htons(port); | |
1308 | + | |
1301 | 1309 | // ipとportからl7vs_child_proto_grpを検索 |
1302 | - grp = l7vs_child_proto_grp_search(ip, port); | |
1310 | + grp = l7vs_child_proto_grp_search(nip, nport); | |
1303 | 1311 | if(grp == NULL) { |
1304 | 1312 | return -1; |
1305 | 1313 | } |