===== net/ipv4/ipvs/ip_vs_sync.c 1.4 vs edited ===== --- 1.4/net/ipv4/ipvs/ip_vs_sync.c 2004-02-19 05:03:17 +08:00 +++ edited/net/ipv4/ipvs/ip_vs_sync.c 2004-10-06 01:33:18 +08:00 @@ -11,6 +11,9 @@ * * ip_vs_sync: sync connection info from master load balancer to backups * through multicast + * + * Changes: + * Justin Ossevoort : Fix endian problem on sync message size. */ #include @@ -254,6 +257,9 @@ char *p; int i; + /* Convert size back to host byte order */ + m->size = ntohs(m->size); + if (buflen != m->size) { IP_VS_ERR("bogus message\n"); return; @@ -517,6 +523,19 @@ return len; } +static void +ip_vs_send_sync_msg(struct socket *sock, struct ip_vs_sync_mesg *msg) +{ + int msize; + + msize = msg->size; + + /* Put size in network byte order */ + msg->size = htons(msg->size); + + if (ip_vs_send_async(sock, (char *)msg, msize) != msize) + IP_VS_ERR("ip_vs_send_async error\n"); +} static int ip_vs_receive(struct socket *sock, char *buffer, const size_t buflen) @@ -561,7 +580,6 @@ { struct socket *sock; struct ip_vs_sync_buff *sb; - struct ip_vs_sync_mesg *m; /* create the sending multicast socket */ sock = make_send_sock(); @@ -570,19 +588,13 @@ for (;;) { while ((sb=sb_dequeue())) { - m = sb->mesg; - if (ip_vs_send_async(sock, (char *)m, - m->size) != m->size) - IP_VS_ERR("ip_vs_send_async error\n"); + ip_vs_send_sync_msg(sock, sb->mesg); ip_vs_sync_buff_release(sb); } /* check if entries stay in curr_sb for 2 seconds */ if ((sb = get_curr_sync_buff(2*HZ))) { - m = sb->mesg; - if (ip_vs_send_async(sock, (char *)m, - m->size) != m->size) - IP_VS_ERR("ip_vs_send_async error\n"); + ip_vs_send_sync_msg(sock, sb->mesg); ip_vs_sync_buff_release(sb); }