aboutsummaryrefslogtreecommitdiffstats
path: root/xenolinux-2.4.21-pre4-sparse
diff options
context:
space:
mode:
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2003-04-20 20:43:57 +0000
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2003-04-20 20:43:57 +0000
commit5fd515c7a4eed5990b74706d2c52391a7c337c3a (patch)
tree1e2e83c212b2b9fc75af1d65adcb19d0d2ea5f9d /xenolinux-2.4.21-pre4-sparse
parent4c3866832c452ea06132c66d76bf885808633fb9 (diff)
downloadxen-5fd515c7a4eed5990b74706d2c52391a7c337c3a.tar.gz
xen-5fd515c7a4eed5990b74706d2c52391a7c337c3a.tar.bz2
xen-5fd515c7a4eed5990b74706d2c52391a7c337c3a.zip
bitkeeper revision 1.184 (3ea3068dWnCzvBRYV1RTpoVK29FlDg)
Many files: Removed the system-wide VIF list -- we now find VIFs via the task hashtable. Fixed a few synchronisation problems.
Diffstat (limited to 'xenolinux-2.4.21-pre4-sparse')
-rw-r--r--xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c8
-rw-r--r--xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/vfr.c327
2 files changed, 173 insertions, 162 deletions
diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c
index c36ab02e96..d3e4752eb3 100644
--- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c
+++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c
@@ -75,15 +75,11 @@ static int cmd_read_proc(char *page, char **start, off_t off,
static ssize_t dom_vif_read(struct file * file, char * buff, size_t size, loff_t * off)
{
- char hyp_buf[128]; // Hypervisor is going to write its reply here.
+ char hyp_buf[128];
network_op_t op;
static int finished = 0;
- // This seems to be the only way to make the OS stop making read requests
- // to the file. When we use the fileoperations version of read, offset
- // seems to be ignored altogether.
-
- if (finished)
+ if ( finished )
{
finished = 0;
return 0;
diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/vfr.c b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/vfr.c
index 13fe25ec9c..852f6943e2 100644
--- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/vfr.c
+++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/vfr.c
@@ -26,7 +26,7 @@ u16 antous(const char *buff, int len);
int anton(const char *buff, int len);
static int vfr_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
+ int count, int *eof, void *data)
{
strcpy(page, readbuf);
*readbuf = '\0';
@@ -60,147 +60,163 @@ static int vfr_read_proc(char *page, char **start, off_t off,
((_x)=='\f') || ((_x)=='\r') || ((_x)=='\n') )
static int vfr_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
+ u_long count, void *data)
{
- network_op_t op;
- int ret, len;
- int ts, te, tl; // token start, end, and length
- int fs, fe, fl; // field.
-
- len = count;
- ts = te = 0;
-
- memset(&op, 0, sizeof(network_op_t));
-
- // get the command:
- while ( count && isspace(buffer[ts]) ) { ts++; count--; } // skip spaces.
- te = ts;
- while ( count && !isspace(buffer[te]) ) { te++; count--; } // command end
- if ( te <= ts ) goto bad;
- tl = te - ts;
-
- if ( strncmp(&buffer[ts], "ADD", tl) == 0 )
- {
- op.cmd = NETWORK_OP_ADDRULE;
- }
- else if ( strncmp(&buffer[ts], "DELETE", tl) == 0 )
- {
- op.cmd = NETWORK_OP_DELETERULE;
- }
- else if ( strncmp(&buffer[ts], "PRINT", tl) == 0 )
- {
- op.cmd = NETWORK_OP_GETRULELIST;
- goto doneparsing;
- }
-
- ts = te;
-
- // get the action
- while ( count && (buffer[ts] == ' ') ) { ts++; count--; } // skip spaces.
- te = ts;
- while ( count && (buffer[te] != ' ') ) { te++; count--; } // command end
- if ( te <= ts ) goto bad;
- tl = te - ts;
-
- if ( strncmp(&buffer[ts], "ACCEPT", tl) == 0 )
- {
- op.u.net_rule.action = NETWORK_ACTION_ACCEPT;
- goto keyval;
- }
- if ( strncmp(&buffer[ts], "COUNT", tl) == 0 )
- {
- op.u.net_rule.action = NETWORK_ACTION_COUNT;
- goto keyval;
- }
-
- // default case;
- return (len);
-
+ network_op_t op;
+ int ret, len;
+ int ts, te, tl; // token start, end, and length
+ int fs, fe, fl; // field.
- // get the key=val pairs.
- keyval:
- while (count)
- {
- //get field
- ts = te; while ( count && isspace(buffer[ts]) ) { ts++; count--; }
- te = ts;
- while ( count && !isspace(buffer[te]) && (buffer[te] != '=') )
- { te++; count--; }
- if ( te <= ts )
- goto doneparsing;
- tl = te - ts;
- fs = ts; fe = te; fl = tl; // save the field markers.
- // skip " = " (ignores extra equals.)
- while ( count && (isspace(buffer[te]) || (buffer[te] == '=')) )
- { te++; count--; }
- ts = te;
- while ( count && !isspace(buffer[te]) ) { te++; count--; }
- tl = te - ts;
+ len = count;
+ ts = te = 0;
- if ( (fl <= 0) || (tl <= 0) ) goto bad;
+ memset(&op, 0, sizeof(network_op_t));
- if (strncmp(&buffer[fs], "srcaddr", fl) == 0)
- {
- op.u.net_rule.src_addr = getipaddr(&buffer[ts], tl);
- }
- else if (strncmp(&buffer[fs], "dstaddr", fl) == 0)
- {
- op.u.net_rule.dst_addr = getipaddr(&buffer[ts], tl);
- }
- else if (strncmp(&buffer[fs], "srcaddrmask", fl) == 0)
- {
- op.u.net_rule.src_addr_mask = getipaddr(&buffer[ts], tl);
- }
- else if (strncmp(&buffer[fs], "dstaddrmask", fl) == 0)
- {
- op.u.net_rule.dst_addr_mask = getipaddr(&buffer[ts], tl);
- }
- else if (strncmp(&buffer[fs], "srcport", fl) == 0)
+ // get the command:
+ while ( count && isspace(buffer[ts]) ) { ts++; count--; } // skip spaces.
+ te = ts;
+ while ( count && !isspace(buffer[te]) ) { te++; count--; } // command end
+ if ( te <= ts ) goto bad;
+ tl = te - ts;
+
+ if ( strncmp(&buffer[ts], "ADD", tl) == 0 )
{
- op.u.net_rule.src_port = antous(&buffer[ts], tl);
+ op.cmd = NETWORK_OP_ADDRULE;
}
- else if (strncmp(&buffer[fs], "dstport", fl) == 0)
+ else if ( strncmp(&buffer[ts], "DELETE", tl) == 0 )
{
- op.u.net_rule.dst_port = antous(&buffer[ts], tl);
+ op.cmd = NETWORK_OP_DELETERULE;
}
- else if (strncmp(&buffer[fs], "srcportmask", fl) == 0)
+ else if ( strncmp(&buffer[ts], "PRINT", tl) == 0 )
{
- op.u.net_rule.src_port_mask = antous(&buffer[ts], tl);
+ op.cmd = NETWORK_OP_GETRULELIST;
+ goto doneparsing;
}
- else if (strncmp(&buffer[fs], "dstportmask", fl) == 0)
+
+ ts = te;
+
+ // get the action
+ while ( count && (buffer[ts] == ' ') ) { ts++; count--; } // skip spaces.
+ te = ts;
+ while ( count && (buffer[te] != ' ') ) { te++; count--; } // command end
+ if ( te <= ts ) goto bad;
+ tl = te - ts;
+
+ if ( strncmp(&buffer[ts], "ACCEPT", tl) == 0 )
{
- op.u.net_rule.dst_port_mask = antous(&buffer[ts], tl);
+ op.u.net_rule.action = NETWORK_ACTION_ACCEPT;
+ goto keyval;
}
- else if (strncmp(&buffer[fs], "srcint", fl) == 0)
+ if ( strncmp(&buffer[ts], "COUNT", tl) == 0 )
{
- op.u.net_rule.src_interface = anton(&buffer[ts], tl);
+ op.u.net_rule.action = NETWORK_ACTION_COUNT;
+ goto keyval;
}
- else if (strncmp(&buffer[fs], "dstint", fl) == 0)
+
+ // default case;
+ return (len);
+
+
+ // get the key=val pairs.
+ keyval:
+ while (count)
{
- op.u.net_rule.dst_interface = anton(&buffer[ts], tl);
- }
- else if ( (strncmp(&buffer[fs], "proto", fl) == 0))
- {
- if (strncmp(&buffer[ts], "any", tl) == 0)
- op.u.net_rule.proto = NETWORK_PROTO_ANY;
- if (strncmp(&buffer[ts], "ip", tl) == 0)
- op.u.net_rule.proto = NETWORK_PROTO_IP;
- if (strncmp(&buffer[ts], "tcp", tl) == 0)
- op.u.net_rule.proto = NETWORK_PROTO_TCP;
- if (strncmp(&buffer[ts], "udp", tl) == 0)
- op.u.net_rule.proto = NETWORK_PROTO_UDP;
- if (strncmp(&buffer[ts], "arp", tl) == 0)
- op.u.net_rule.proto = NETWORK_PROTO_ARP;
-
+ //get field
+ ts = te; while ( count && isspace(buffer[ts]) ) { ts++; count--; }
+ te = ts;
+ while ( count && !isspace(buffer[te]) && (buffer[te] != '=') )
+ { te++; count--; }
+ if ( te <= ts )
+ goto doneparsing;
+ tl = te - ts;
+ fs = ts; fe = te; fl = tl; // save the field markers.
+ // skip " = " (ignores extra equals.)
+ while ( count && (isspace(buffer[te]) || (buffer[te] == '=')) )
+ { te++; count--; }
+ ts = te;
+ while ( count && !isspace(buffer[te]) ) { te++; count--; }
+ tl = te - ts;
+
+ if ( (fl <= 0) || (tl <= 0) ) goto bad;
+
+ /* NB. Prefix matches must go first! */
+ if (strncmp(&buffer[fs], "src", fl) == 0)
+ {
+ op.u.net_rule.src_vif = VIF_ANY_INTERFACE;
+ }
+ else if (strncmp(&buffer[fs], "dst", fl) == 0)
+ {
+ op.u.net_rule.dst_vif = VIF_PHYSICAL_INTERFACE;
+ }
+ else if (strncmp(&buffer[fs], "srcaddr", fl) == 0)
+ {
+ op.u.net_rule.src_addr = getipaddr(&buffer[ts], tl);
+ }
+ else if (strncmp(&buffer[fs], "dstaddr", fl) == 0)
+ {
+ op.u.net_rule.dst_addr = getipaddr(&buffer[ts], tl);
+ }
+ else if (strncmp(&buffer[fs], "srcaddrmask", fl) == 0)
+ {
+ op.u.net_rule.src_addr_mask = getipaddr(&buffer[ts], tl);
+ }
+ else if (strncmp(&buffer[fs], "dstaddrmask", fl) == 0)
+ {
+ op.u.net_rule.dst_addr_mask = getipaddr(&buffer[ts], tl);
+ }
+ else if (strncmp(&buffer[fs], "srcport", fl) == 0)
+ {
+ op.u.net_rule.src_port = antous(&buffer[ts], tl);
+ }
+ else if (strncmp(&buffer[fs], "dstport", fl) == 0)
+ {
+ op.u.net_rule.dst_port = antous(&buffer[ts], tl);
+ }
+ else if (strncmp(&buffer[fs], "srcportmask", fl) == 0)
+ {
+ op.u.net_rule.src_port_mask = antous(&buffer[ts], tl);
+ }
+ else if (strncmp(&buffer[fs], "dstportmask", fl) == 0)
+ {
+ op.u.net_rule.dst_port_mask = antous(&buffer[ts], tl);
+ }
+ else if (strncmp(&buffer[fs], "srcdom", fl) == 0)
+ {
+ op.u.net_rule.src_vif |= anton(&buffer[ts], tl)<<VIF_DOMAIN_SHIFT;
+ }
+ else if (strncmp(&buffer[fs], "srcidx", fl) == 0)
+ {
+ op.u.net_rule.src_vif |= anton(&buffer[ts], tl);
+ }
+ else if (strncmp(&buffer[fs], "dstdom", fl) == 0)
+ {
+ op.u.net_rule.dst_vif |= anton(&buffer[ts], tl)<<VIF_DOMAIN_SHIFT;
+ }
+ else if (strncmp(&buffer[fs], "dstidx", fl) == 0)
+ {
+ op.u.net_rule.dst_vif |= anton(&buffer[ts], tl);
+ }
+ else if ( (strncmp(&buffer[fs], "proto", fl) == 0))
+ {
+ if (strncmp(&buffer[ts], "any", tl) == 0)
+ op.u.net_rule.proto = NETWORK_PROTO_ANY;
+ if (strncmp(&buffer[ts], "ip", tl) == 0)
+ op.u.net_rule.proto = NETWORK_PROTO_IP;
+ if (strncmp(&buffer[ts], "tcp", tl) == 0)
+ op.u.net_rule.proto = NETWORK_PROTO_TCP;
+ if (strncmp(&buffer[ts], "udp", tl) == 0)
+ op.u.net_rule.proto = NETWORK_PROTO_UDP;
+ if (strncmp(&buffer[ts], "arp", tl) == 0)
+ op.u.net_rule.proto = NETWORK_PROTO_ARP;
+ }
}
- }
doneparsing:
- ret = HYPERVISOR_network_op(&op);
- return(len);
+ ret = HYPERVISOR_network_op(&op);
+ return(len);
bad:
- return(len);
+ return(len);
}
@@ -256,51 +272,50 @@ int anton(const char *buff, int len)
u16 antous(const char *buff, int len)
{
- u16 ret;
- char c;
+ u16 ret;
+ char c;
- ret = 0;
+ ret = 0;
- while ( (len) && ((c = *buff) >= '0') && (c <= '9') )
- {
- ret *= 10;
- ret += c - '0';
- buff++; len--;
- }
+ while ( (len) && ((c = *buff) >= '0') && (c <= '9') )
+ {
+ ret *= 10;
+ ret += c - '0';
+ buff++; len--;
+ }
- return ret;
+ return ret;
}
u32 getipaddr(const char *buff, unsigned int len)
{
- int i;
- char c;
- u32 ret, val;
+ char c;
+ u32 ret, val;
- ret = 0; val = 0;
+ ret = 0; val = 0;
- while ( len )
- {
- if (!((((c = *buff) >= '0') && ( c <= '9')) || ( c == '.' ) ) )
+ while ( len )
{
- return(0); // malformed.
+ if (!((((c = *buff) >= '0') && ( c <= '9')) || ( c == '.' ) ) )
+ {
+ return(0); // malformed.
+ }
+
+ if ( c == '.' ) {
+ if (val > 255) return (0); //malformed.
+ ret = ret << 8;
+ ret += val;
+ val = 0;
+ len--; buff++;
+ continue;
+ }
+ val *= 10;
+ val += c - '0';
+ buff++; len--;
}
+ ret = ret << 8;
+ ret += val;
- if ( c == '.' ) {
- if (val > 255) return (0); //malformed.
- ret = ret << 8;
- ret += val;
- val = 0;
- len--; buff++;
- continue;
- }
- val *= 10;
- val += c - '0';
- buff++; len--;
- }
- ret = ret << 8;
- ret += val;
-
- return (ret);
+ return (ret);
}