* [PATCH] [IPVS] Fix endian problem on sync message size
@ 2004-10-05 18:20 Wensong Zhang
2004-10-05 18:43 ` David S. Miller
0 siblings, 1 reply; 2+ messages in thread
From: Wensong Zhang @ 2004-10-05 18:20 UTC (permalink / raw)
To: David S. Miller, netdev
[-- Attachment #1: Type: TEXT/PLAIN, Size: 209 bytes --]
Hi Dave,
Here is the patch from Justin Ossevoort <justin@snt.utwente.nl> to fix
endian problem on IPVS sync message size. Please check and apply them to
kernel 2.4 and 2.6 respectively.
Thanks,
Wensong
[-- Attachment #2: Type: TEXT/PLAIN, Size: 1893 bytes --]
===== 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 <linux/module.h>
@@ -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);
}
[-- Attachment #3: Type: TEXT/PLAIN, Size: 1916 bytes --]
===== net/ipv4/ipvs/ip_vs_sync.c 1.10 vs edited =====
--- 1.10/net/ipv4/ipvs/ip_vs_sync.c 2004-07-16 22:13:53 +08:00
+++ edited/net/ipv4/ipvs/ip_vs_sync.c 2004-10-03 01:24:42 +08:00
@@ -16,6 +16,7 @@
* Alexandre Cassen : Added master & backup support at a time.
* Alexandre Cassen : Added SyncID support for incoming sync
* messages filtering.
+ * Justin Ossevoort : Fix endian problem on sync message size.
*/
#include <linux/module.h>
@@ -279,6 +280,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;
@@ -569,6 +573,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)
@@ -605,7 +622,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();
@@ -618,19 +634,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);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] [IPVS] Fix endian problem on sync message size
2004-10-05 18:20 [PATCH] [IPVS] Fix endian problem on sync message size Wensong Zhang
@ 2004-10-05 18:43 ` David S. Miller
0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2004-10-05 18:43 UTC (permalink / raw)
To: Wensong Zhang; +Cc: netdev
On Wed, 6 Oct 2004 02:20:18 +0800 (CST)
Wensong Zhang <wensong@linux-vs.org> wrote:
> Here is the patch from Justin Ossevoort <justin@snt.utwente.nl> to fix
> endian problem on IPVS sync message size. Please check and apply them to
> kernel 2.4 and 2.6 respectively.
Patch applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-10-05 18:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-05 18:20 [PATCH] [IPVS] Fix endian problem on sync message size Wensong Zhang
2004-10-05 18:43 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).