March 2024  |  01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

PBSProのTPP init failedについて

JUGEMテーマ:コンピュータ

 

インストールできたものの、TPP初期化の失敗で終わってしまったPBSPro、原因を調べてみたところ、ホスト名(PBSサーバ名)に関係していた。

 

TCP通信に関するエラーなので、OSのネットワークセキュリティがらみの制限にひかかったのではないかと思い、SELinuxのログを調べたが、それらしいものはなにもなかった。次に、原因がlocalhostというホスト名にあるのではという想像でホスト名を付け替えてみたが、実行結果エラーは変わらなかった(実はやり方が半端※)。結局、ソースコードを追っかけることにした。それらしいところに検討をつけて、ファイルを開きつつ読み始めたが途中で疲れてきた。そして、デバッガを使うことにした。デバッガで、処理をトレースしてみたところ、サーバとしてループバックアドレスを使えないことがわかった。

 

※ KVMで起動してテンプレート化したいため固有のアドレスを割り当てるのが嫌で、ホスト名を変更する際にその名前をループバックアドレスのlocalhost の行に追加していた。

 

SELinuxによるエラーチェック

 

まず、SELinuxの監査ログから簡単に情報を得るには、policycoreutils-python パッケージをインストールして audit2allow コマンドを実行する。

# yum install policycoreutils-python

# audit2allow -aw

すると、問題があれば、SELinuxに関する設定方法についての情報が出てくるはずなのだが、それらしい情報は見つからなかった。

 

 

ホスト名の変更

 

次に、ホスト名の設定。ホスト名の設定は、hostname コマンドでできる。OS起動時のホスト名の設定は /etc/hostname に書き込んでおけばよい。hostname コマンドは -F オプションでファイルからホスト名を設定できるので次のように設定する。

(ここでは、pbshost.localdomain)

# echo "pbshost.localdomain" > /etc/hostname

# hostname -F /etc/hostname

ホスト名からアドレスの解決のために /etc/hosts ファイルに設定したホスト名を追加しておく。

(KVMのテンプレートイメージにしておきたかったので、あえて、localhost と同じループバックアドレスにした。実は、これが失敗の原因だったと後で知ることとなる。)

# vi /etc/hosts

127.0.0.1    localhost localhost.localdomain ... pbshost pbshost.localdomain

この状態で、PBSProを再インストールしてみても状況はかわらず。念のためリブート後の再インストールでも同様だった。

【注意】再インストールは、次のようにPBSProをアンインストールし、関連ファイルを削除した後に行った。

# yum erase pbspro-server

...

# rm -rf /var/spool/pbs

# rm -f /etc/pbs.pro

再インストール後に、 /etc/pbs.conf でサーバ名の設定は次のようになっていることを確認している。

...

PBS_SERVER=pbshost

...

 

 

ソースコードの目視調査

 

少し途方に暮れ気味となったが気を取り直し、ここはオープンソースなので、素直にソースコードを読むことにした。

pbs_commのログから、"Failed to resolve address" の行に関数名らしき "alloc_router" があったので、これを含むファイルを探してみる。

 

$ grep -r alloc_router *
src/lib/Libtpp/tpp_router.c:alloc_router(char *name, tpp_addr_t *address)
src/lib/Libtpp/tpp_router.c:                                    r = alloc_router(strdup(tpp_netaddr(&connected_host)), &connected_host);
src/lib/Libtpp/tpp_router.c:    r = alloc_router(tpp_conf->node_name, NULL);
src/lib/Libtpp/tpp_router.c:            r = alloc_router(tpp_conf->routers[j], NULL);

見つかった、src/lib/Libtpp/tpp_router.c を開いて、呼び出しの前後を見てみる。

$ vi src/lib/Libtpp/tpp_router.c
...
 136         if (address == NULL) {
 137                 /* do name resolution on the supplied name */
 138                 addrs = tpp_get_addresses(r->router_name, &count);
 139                 if (!addrs) {
 140                         snprintf(tpp_get_logbuf(), TPP_LOGBUF_SZ, "Failed to resolve address, pbs_comm=%s", r->router_name);
 141                         tpp_log_func(LOG_CRIT, __func__, tpp_get_logbuf());
 142                         free_router(r);
 143                         return NULL;
...

"Failed to resolve address"という文字列が使われる前に、"tpp_get_addresses" 関数呼び出し結果が使われている。

続けて、"tpp_get_addresses"を含むファイルを探してみる。

 

$ grep -r tpp_get_addresses *
src/lib/Libtpp/tpp_client.c:    leaf_addrs = tpp_get_addresses(tpp_conf->node_name, &leaf_addr_count);
src/lib/Libtpp/tpp_client.c:    addrs = tpp_get_addresses(dest, &count);
src/lib/Libtpp/tpp_router.c:            addrs = tpp_get_addresses(r->router_name, &count);
src/lib/Libtpp/tpp_util.c:tpp_get_addresses(char *node_name, int *count)
src/lib/Libtpp/tpp_common.h:tpp_addr_t *tpp_get_addresses(char *node_name, int *leaf_addr_count);

いくつか、ファイルが見つかったが、src/lib/Libtpp/tpp_util.c でこの関数が定義されているらしいことがわかる。

見つかった、src/lib/Libtpp/tpp_util.c を開いて、tpp_get_addresses関数を見てみる。

$ vi rc/lib/Libtpp/tpp_util.c
...
1535 tpp_get_addresses(char *node_name, int *count)
1536 {
1537         int port;
1538         char *host;
1539         tpp_addr_t *addrs = NULL;
1540         int i;
1541
1542         *count = 0;
1543
1544         /* parse our name and port */
1545         host = tpp_parse_hostname(node_name, &port);
1546
1547         addrs = tpp_sock_resolve_host(host, count); /* get all ipv4, ipv6 a     ddresses */
1548         if (!addrs) {
1549                 free(host);
1550                 return NULL;

この関数の中では、さらに "tpp_sock_resolve_host" 関数を呼び出しているが、結果によりさらに次の処理に進むこともある。この変で値を特定したり、さらにファイルを探して見るのも面倒になってきたので、デバッガを使って追いかけてみることにした。

 

 

デバッガによるプログラムのトレース

 

まず、デバッガプログラムの gdb をインストールする。

# yum install gdb

また、PBSProのRPMに、PBSProに含まれるバイナリ実行プログラムのデバッグ情報のパッケージも用意されているので、これをインストールする。

# yum install pbspro-debuginfo

...

そして、gdbを実行する。

# gdb /opt/pbs/sbin/pbs_comm
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-100.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /opt/pbs/sbin/pbs_comm...Reading symbols from /usr/lib/debug/opt/pbs/sbin/pbs_comm.debug...done.
done.

(gdb) r
Starting program: /opt/pbs/sbin/pbs_comm
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Detaching after fork from child process 9283.
/opt/pbs/sbin/pbs_comm ready (pid=9283), Proxy Name:localhost:17001, Threads:4
[Inferior 1 (process 9279) exited normally]
Missing separate debuginfos, use: debuginfo-install glibc-2.17-196.el7.x86_64 nss-softokn-freebl-3.28.3-8.el7_4.x86_64 sssd-client-1.15.2-50.el7_4.2.x86_64
(gdb) q

すると、エラーメッセージが出力されて、実行されないので、そのメッセージの内容を実行する。

# debuginfo-install glibc-2.17-196.el7.x86_64 nss-softokn-freebl-3.28.3-8.el7_4.x86_64 sssd-client-1.15.2-50.el7_4.2.x86_64

...

これで、デバッグ環境が整うので、gdbを実行する。

# gdb /opt/pbs/sbin/pbs_comm
 

...
(gdb) l
931                     name = pbs_conf.pbs_comm_name;
932                     host = tpp_parse_hostname(name, &port);
933                     if (host)
934                             snprintf(server_host, sizeof(server_host), "%s", host);
935                     free(host);
936                     host = NULL;
937             } else if (pbs_conf.pbs_leaf_name) {
938                     name = pbs_conf.pbs_leaf_name;
939                     host = tpp_parse_hostname(name, &port);
940                     if (host)

(gdb) b 939
Breakpoint 1 at 0x4032b6: file ../../../src/server/pbs_comm.c, line 939.
(gdb) b 932
Breakpoint 2 at 0x403497: file ../../../src/server/pbs_comm.c, line 932.
(gdb) r
Starting program: /opt/pbs/sbin/pbs_comm
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Breakpoint 2, main (argc=1, argv=0x7fffffffebe8)
    at ../../../src/server/pbs_comm.c:937
937             } else if (pbs_conf.pbs_leaf_name) {

(gdb) n
945                     if (gethostname(server_host, (sizeof(server_host) - 1)) == -1) {

(gdb) n
959                     name = server_host;
(gdb) p server_host
$3 = "localhost.localdomain", '¥000' <repeats 234 times>

...

1070            if (stalone != 1)
(gdb) n
1071                    go_to_background();
(gdb) p stalone
$24 = 0
(gdb) n
Detaching after fork from child process 9359.
/opt/pbs/sbin/pbs_comm ready (pid=9359), Proxy Name:localhost:17001, Threads:4
[Inferior 1 (process 9333) exited normally]

(gdb) q

どうも、バックグラウンドプロセスをフォークして終わってしまったようだ。こうならないようなオプションはないものかと、オンラインマニュアルを調べる。

[root@localhost pbs]# man pbs_comm
pbs_comm(8B)                   PBS Professional                   pbs_comm(8B)

NAME
       pbs_comm - start the PBS communication daemon

SYNOPSIS
       UNIX/Linux:
       pbs_comm [-N] [-r <other routers>] [-t <number of threads>]
       pbs_comm --version

       Windows:
       pbs_comm.exe [-R | -U | -N] [-r <other routers>]
                    [-t <number of threads>]
       pbs_comm --version

DESCRIPTION
       The  PBS  communication daemon, pbs_comm, handles communication between
       daemons, except for scheduler-server and  server-server  communication,
       which  uses  TCP.  The server, scheduler, and MoMs are connected by one
       or more pbs_comm daemons.

OPTIONS
       -N        Runs the communication daemon in standalone mode.

       -r        Used to specify the list of other pbs_comm daemons  to  which
q

[root@localhost pbs]#

-N オプションでstandalone モードになるとわかったので、これを使ってみる。

 

# gdb /opt/pbs/sbin/pbs_comm

...

(gdb) l 1147
1142    #endif  /* WIN32 */
1143
1144            conf.node_type = TPP_ROUTER_NODE;
1145            conf.numthreads = numthreads;
1146
1147            if ((rpp_fd = tpp_init_router(&conf)) == -1) {
1148                    log_err(-1, __func__, "tpp init failed¥n");
1149                    return 1;
1150            }
1151
(gdb) b 1144
Breakpoint 1 at 0x403c8a: file ../../../src/server/pbs_comm.c, line 1144.

1144            conf.node_type = TPP_ROUTER_NODE;
(gdb) n
1145            conf.numthreads = numthreads;
(gdb) n
1147            if ((rpp_fd = tpp_init_router(&conf)) == -1) {
(gdb) p conf
$1 = {node_type = 3, routers = 0x0, numthreads = 4,
  node_name = 0x636bb0 "localhost:17001", auth_type = 1 '¥001',
  get_ext_auth_data = 0x0, validate_ext_auth_data = 0x0, compress = 0,
  tcp_keepalive = 1, tcp_keep_idle = 30, tcp_keep_intvl = 10,
  tcp_keep_probes = 3, buf_limit_per_conn = 5000, force_fault_tolerance = 0}
(gdb) s
tpp_init_router (cnf=cnf@entry=0x7fffffffdbd0)
    at ../../../../src/lib/Libtpp/tpp_router.c:1971
1971    {
(gdb) l

1966     * @par MT-safe: Yes
1967     *
1968     */
1969    int
1970    tpp_init_router(struct tpp_config *cnf)
1971    {
1972            int j;
1973            tpp_router_t *r;
1974            tpp_context_t *ctx = NULL;
1975
(gdb)
1976            tpp_conf = cnf;
1977
1978            /* before doing anything else, initialize the key to the tls */
1979            if (tpp_init_tls_key() != 0) {
1980                    /* can only use prints since tpp key init failed */
1981                    fprintf(stderr, "Failed to initialize tls key¥n");
1982                    return -1;
1983            }
1984
1985            if (tpp_addr_cache_init() != 0) {
(gdb) n
1976            tpp_conf = cnf;
(gdb)
1979            if (tpp_init_tls_key() != 0) {
(gdb)
1985            if (tpp_addr_cache_init() != 0) {
(gdb)
1990            tpp_init_lock(&router_lock);
(gdb)
1992            AVL_routers = tpp_create_tree(AVL_NO_DUP_KEYS, sizeof(tpp_addr_t));
(gdb) n
1993            if (AVL_routers == NULL) {
(gdb) p AVL_routers
$2 = (AVL_IX_DESC *) 0x0
(gdb) b 1992
Breakpoint 2 at 0x407bfa: file ../../../../src/lib/Libtpp/tpp_router.c, line 1992.
(gdb) n
1992            AVL_routers = tpp_create_tree(AVL_NO_DUP_KEYS, sizeof(tpp_addr_t));

(gdb) s
1993            if (AVL_routers == NULL) {
(gdb) n
1998            AVL_cluster_leaves = tpp_create_tree(AVL_NO_DUP_KEYS, sizeof(tpp_addr_t));
(gdb) s
tpp_create_tree (dups=dups@entry=0, keylen=keylen@entry=20)
    at ../../../../src/lib/Libtpp/tpp_util.c:671
671     {
(gdb) l
666      * @par MT-safe: Yes
667      *
668      */
669     AVL_IX_DESC *
670     tpp_create_tree(int dups, int keylen)
671     {
672             AVL_IX_DESC *AVL_p = NULL;
673
674             AVL_p = (AVL_IX_DESC *) malloc(sizeof(AVL_IX_DESC));
675             if (AVL_p == NULL)
(gdb) n
674             AVL_p = (AVL_IX_DESC *) malloc(sizeof(AVL_IX_DESC));
(gdb) l
669     AVL_IX_DESC *
670     tpp_create_tree(int dups, int keylen)
671     {
672             AVL_IX_DESC *AVL_p = NULL;
673
674             AVL_p = (AVL_IX_DESC *) malloc(sizeof(AVL_IX_DESC));
675             if (AVL_p == NULL)
676                     return (NULL);
677
678             avl_create_index(AVL_p, dups, keylen);
(gdb) l
679             return AVL_p;
680     }
681
682     /**
683      * @brief
684      *      Find a node from the AVL tree based on the supplied key
685      *
686      * @param[in] - root   - The root of the AVL tree to search
687      * @param[in] - key - String to be used as the key
688      *
(gdb) n
671     {
(gdb)
674             AVL_p = (AVL_IX_DESC *) malloc(sizeof(AVL_IX_DESC));
(gdb)
675             if (AVL_p == NULL)
(gdb) n
674             AVL_p = (AVL_IX_DESC *) malloc(sizeof(AVL_IX_DESC));
(gdb) n
675             if (AVL_p == NULL)
(gdb)
678             avl_create_index(AVL_p, dups, keylen);
(gdb) p keylen
$3 = 20
(gdb) p dups
$4 = 0
(gdb) n
680     }
(gdb) p AVL_p
$5 = (AVL_IX_DESC *) 0x634660
(gdb) p *AVL_p
$6 = {root = 0x0, keylength = 20, dup_keys = 0}
(gdb) n
tpp_init_router (cnf=cnf@entry=0x7fffffffdbd0)
    at ../../../../src/lib/Libtpp/tpp_router.c:1999
1999            if (AVL_cluster_leaves == NULL) {
(gdb)
1998            AVL_cluster_leaves = tpp_create_tree(AVL_NO_DUP_KEYS, sizeof(tpp_addr_t));
(gdb) n
1999            if (AVL_cluster_leaves == NULL) {
(gdb) p AVL_cluster_leaves
$7 = (AVL_IX_DESC *) 0x634660
(gdb) p *AVL_cluster_leaves
$8 = {root = 0x0, keylength = 20, dup_keys = 0}
(gdb) n
2004            AVL_my_leaves_notify = tpp_create_tree(AVL_NO_DUP_KEYS, sizeof(tpp_addr_t));
(gdb) n
2005            if (AVL_my_leaves_notify == NULL) {
(gdb) n
2004            AVL_my_leaves_notify = tpp_create_tree(AVL_NO_DUP_KEYS, sizeof(tpp_addr_t));
(gdb)
2005            if (AVL_my_leaves_notify == NULL) {
(gdb)
2010            r = alloc_router(tpp_conf->node_name, NULL);
(gdb) p tpp_conf->node_name
$9 = 0x636bb0 "localhost:17001"
(gdb) s
alloc_router (name=0x636bb0 "localhost:17001", address=address@entry=0x0)
    at ../../../../src/lib/Libtpp/tpp_router.c:118
118     {
(gdb) l
113     /* structure identifying this router */
114     static tpp_router_t *this_router = NULL;
115
116     static tpp_router_t *
117     alloc_router(char *name, tpp_addr_t *address)
118     {
119             tpp_router_t *r = NULL;
120             tpp_addr_t *addrs = NULL;
121             int count = 0;
122
(gdb) n
124             r = (tpp_router_t *) calloc(1, sizeof(tpp_router_t));
(gdb)
118     {
(gdb) n
124             r = (tpp_router_t *) calloc(1, sizeof(tpp_router_t));
(gdb) n
118     {
(gdb)
121             int count = 0;
(gdb)
124             r = (tpp_router_t *) calloc(1, sizeof(tpp_router_t));
(gdb)
125             if (!r) {
(gdb)
124             r = (tpp_router_t *) calloc(1, sizeof(tpp_router_t));
(gdb) p tpp_router_t
Attempt to use a type name as an expression
(gdb) p r
$10 = (tpp_router_t *) 0x0
(gdb) n
125             if (!r) {
(gdb) p r
$11 = (tpp_router_t *) 0x6346a0
(gdb) p *r
$12 = {router_name = 0x0, router_addr = {ip = {0, 0, 0, 0}, port = 0,
    family = 0 '¥000'}, conn_fd = 0, conn_time = 0, initiator = 0, state = 0,
  delay = 0, index = 0, AVL_my_leaves = 0x0}
(gdb) n
136             if (address == NULL) {
(gdb)
130             r->conn_fd = -1;
(gdb)
131             r->router_name = name;
(gdb)
132             r->initiator = 0;
(gdb) p name
$13 = 0x636bb0 "localhost:17001"
(gdb) n
133             r->index = 0; /* index is not used between routers */
(gdb)
134             r->state = TPP_ROUTER_STATE_DISCONNECTED;
(gdb)
136             if (address == NULL) {
(gdb) p r
$14 = (tpp_router_t *) 0x6346a0
(gdb) p *r
$15 = {router_name = 0x636bb0 "localhost:17001", router_addr = {ip = {0, 0, 0,
      0}, port = 0, family = 0 '¥000'}, conn_fd = -1, conn_time = 0,
  initiator = 0, state = 0, delay = 0, index = 0, AVL_my_leaves = 0x0}
(gdb) n
138                     addrs = tpp_get_addresses(r->router_name, &count);
(gdb) s
tpp_get_addresses (node_name=node_name@entry=0x636bb0 "localhost:17001",
    count=count@entry=0x7fffffffdb4c)
    at ../../../../src/lib/Libtpp/tpp_util.c:1691
1691    {
(gdb) l
1686     *
1687     * @par MT-safe: Yes
1688     **/
1689    tpp_addr_t *
1690    tpp_get_addresses(char *node_name, int *count)
1691    {
1692            int port;
1693            char *host;
1694            tpp_addr_t *addrs = NULL;
1695            int i;
(gdb)
1696
1697            *count = 0;
1698
1699            /* parse our name and port */
1700            host = tpp_parse_hostname(node_name, &port);
1701
1702            addrs = tpp_sock_resolve_host(host, count); /* get all ipv4, ipv6 addresses */
1703            if (!addrs) {
1704                    free(host);
1705                    return NULL;
(gdb) n
1697            *count = 0;
(gdb) n
1700            host = tpp_parse_hostname(node_name, &port);
(gdb) p node_name
$16 = 0x636bb0 "localhost:17001"
(gdb) n
1702            addrs = tpp_sock_resolve_host(host, count); /* get all ipv4, ipv6 addresses */
(gdb) p host
$17 = <optimized out>
(gdb) s
1700            host = tpp_parse_hostname(node_name, &port);
(gdb) n
1702            addrs = tpp_sock_resolve_host(host, count); /* get all ipv4, ipv6 addresses */
(gdb) p host
$18 = 0x637aa0 "localhost"
(gdb) s
tpp_sock_resolve_host (host=host@entry=0x637aa0 "localhost",
    count=count@entry=0x7fffffffdb4c)
    at ../../../../src/lib/Libtpp/tpp_platform.c:703
703     {
(gdb) n
716             errno = 0;
(gdb) n
720             if ((ips = tpp_lookup_addr_cache(host, count)) != NULL)
(gdb) n
716             errno = 0;
(gdb) p ips
$19 = (tpp_addr_t *) 0x0
(gdb) s
720             if ((ips = tpp_lookup_addr_cache(host, count)) != NULL)
(gdb)
717             *count = 0;
(gdb) p ips
$20 = (tpp_addr_t *) 0x0

...

(gdb) n
757                     if (aip->ai_family == AF_INET) { /* for now only work with IPv4 */
(gdb) n
759                                     struct sockaddr_in *sa = (struct sockaddr_in *) aip->ai_addr;
(gdb) n
760                                     if (ntohl(sa->sin_addr.s_addr) >> 24 == IN_LOOPBACKNET)
(gdb) p sa->sin_addr.s_addr
$50 = 16777343
(gdb) p ntohl(sa->sin_addr.s_addr)
$51 = 2130706433
(gdb) p ntohl(sa->sin_addr.s_addr) >> 24
$52 = 127
(gdb) n
tpp_sock_resolve_host (host=host@entry=0x637aa0 "localhost",
    count=count@entry=0x7fffffffdb4c)
    at ../../../../src/lib/Libtpp/tpp_platform.c:760
760                                     if (ntohl(sa->sin_addr.s_addr) >> 24 == IN_LOOPBACKNET)
(gdb) n
754             for (aip = pai; aip != NULL; aip = aip->ai_next) {

(gdb) n
757                     if (aip->ai_family == AF_INET) { /* for now only work with IPv4 */
(gdb)
759                                     struct sockaddr_in *sa = (struct sockaddr_in *) aip->ai_addr;
(gdb)
760                                     if (ntohl(sa->sin_addr.s_addr) >> 24 == IN_LOOPBACKNET)
(gdb)
754             for (aip = pai; aip != NULL; aip = aip->ai_next) {

(gdb) l
749                     *count = 0;
750                     return NULL;
751             }
752
753             i = 0;
754             for (aip = pai; aip != NULL; aip = aip->ai_next) {
755                     /* skip non-IPv4 addresses */
756                     /*if (aip->ai_family == AF_INET || aip->ai_family == AF_INET6) {*/
757                     if (aip->ai_family == AF_INET) { /* for now only work with IPv4 */
758                             if (aip->ai_family == AF_INET) {
(gdb)
759                                     struct sockaddr_in *sa = (struct sockaddr_in *) aip->ai_addr;
760                                     if (ntohl(sa->sin_addr.s_addr) >> 24 == IN_LOOPBACKNET)
761                                             continue;
762                                     memcpy(&ips[i].ip, &sa->sin_addr, sizeof(sa->sin_addr));
763                             } else if (aip->ai_family == AF_INET6) {
764                                     struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *) aip->ai_addr;
765                                     memcpy(&ips[i].ip, &sa6->sin6_addr, sizeof(sa6->sin6_addr));
766                             }
767                             ips[i].family = (aip->ai_family == AF_INET6)? TPP_ADDR_FAMILY_IPV6 : TPP_ADDR_FAMILY_IPV4;
768                             ips[i].port = 0;
(gdb) n

782             freeaddrinfo(pai);
(gdb)
784             if (i == 0) {
(gdb) p pai
$53 = (struct addrinfo *) 0x637b90
(gdb) p *pai
$54 = {ai_flags = 0, ai_family = 0, ai_socktype = 1, ai_protocol = 6,
  ai_addrlen = 16, ai_addr = 0x637bc0, ai_canonname = 0x0, ai_next = 0x637be0}
(gdb) n
785                     free(ips);

(gdb) q

結局、tpp_plathome.c の760行目で、ネットワークアドレスがIN_LOOPBACKNETの場合に、処理されないことがわかった。

760                                     if (ntohl(sa->sin_addr.s_addr) >> 24 == IN_LOOPBACKNET)
761                                             continue;

ちなみに、ソースコードからIN_LOOPBACKNETを探して見ると次のとおり。

$ grep -r IN_LOOPBACKNET *
src/include/pbs_internal.h:#ifndef IN_LOOPBACKNET
src/include/pbs_internal.h:#define IN_LOOPBACKNET       127
src/lib/Libtpp/tpp_platform.c:                          if (ntohl(sa->sin_addr.s_addr) >> 24 == IN_LOOPBACKNET)
src/lib/Libifl/get_hostname.c:          if (ntohl(inp->sin_addr.s_addr) >> 24 != IN_LOOPBACKNET) {

src/include/pbs_internal.h で、IN_LOOPBACKNETは、ループバックのネットワークアドレスである 127 に定義されている。

 

 

 

スポンサーサイト

comments

   

trackback

pagetop