diff options
-rw-r--r-- | net/x25/af_x25.c | 20 | ||||
-rw-r--r-- | net/x25/x25_facilities.c | 15 |
2 files changed, 28 insertions, 7 deletions
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index fe26c01ef3e6..8ed51c926c50 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c | |||
@@ -588,7 +588,8 @@ static int x25_create(struct net *net, struct socket *sock, int protocol, | |||
588 | x25->facilities.winsize_out = X25_DEFAULT_WINDOW_SIZE; | 588 | x25->facilities.winsize_out = X25_DEFAULT_WINDOW_SIZE; |
589 | x25->facilities.pacsize_in = X25_DEFAULT_PACKET_SIZE; | 589 | x25->facilities.pacsize_in = X25_DEFAULT_PACKET_SIZE; |
590 | x25->facilities.pacsize_out = X25_DEFAULT_PACKET_SIZE; | 590 | x25->facilities.pacsize_out = X25_DEFAULT_PACKET_SIZE; |
591 | x25->facilities.throughput = X25_DEFAULT_THROUGHPUT; | 591 | x25->facilities.throughput = 0; /* by default don't negotiate |
592 | throughput */ | ||
592 | x25->facilities.reverse = X25_DEFAULT_REVERSE; | 593 | x25->facilities.reverse = X25_DEFAULT_REVERSE; |
593 | x25->dte_facilities.calling_len = 0; | 594 | x25->dte_facilities.calling_len = 0; |
594 | x25->dte_facilities.called_len = 0; | 595 | x25->dte_facilities.called_len = 0; |
@@ -1459,9 +1460,20 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1459 | if (facilities.winsize_in < 1 || | 1460 | if (facilities.winsize_in < 1 || |
1460 | facilities.winsize_in > 127) | 1461 | facilities.winsize_in > 127) |
1461 | break; | 1462 | break; |
1462 | if (facilities.throughput < 0x03 || | 1463 | if (facilities.throughput) { |
1463 | facilities.throughput > 0xDD) | 1464 | int out = facilities.throughput & 0xf0; |
1464 | break; | 1465 | int in = facilities.throughput & 0x0f; |
1466 | if (!out) | ||
1467 | facilities.throughput |= | ||
1468 | X25_DEFAULT_THROUGHPUT << 4; | ||
1469 | else if (out < 0x30 || out > 0xD0) | ||
1470 | break; | ||
1471 | if (!in) | ||
1472 | facilities.throughput |= | ||
1473 | X25_DEFAULT_THROUGHPUT; | ||
1474 | else if (in < 0x03 || in > 0x0D) | ||
1475 | break; | ||
1476 | } | ||
1465 | if (facilities.reverse && | 1477 | if (facilities.reverse && |
1466 | (facilities.reverse & 0x81) != 0x81) | 1478 | (facilities.reverse & 0x81) != 0x81) |
1467 | break; | 1479 | break; |
diff --git a/net/x25/x25_facilities.c b/net/x25/x25_facilities.c index a2765c6b1f1a..771bab00754b 100644 --- a/net/x25/x25_facilities.c +++ b/net/x25/x25_facilities.c | |||
@@ -269,9 +269,18 @@ int x25_negotiate_facilities(struct sk_buff *skb, struct sock *sk, | |||
269 | new->reverse = theirs.reverse; | 269 | new->reverse = theirs.reverse; |
270 | 270 | ||
271 | if (theirs.throughput) { | 271 | if (theirs.throughput) { |
272 | if (theirs.throughput < ours->throughput) { | 272 | int theirs_in = theirs.throughput & 0x0f; |
273 | SOCK_DEBUG(sk, "X.25: throughput negotiated down\n"); | 273 | int theirs_out = theirs.throughput & 0xf0; |
274 | new->throughput = theirs.throughput; | 274 | int ours_in = ours->throughput & 0x0f; |
275 | int ours_out = ours->throughput & 0xf0; | ||
276 | if (!ours_in || theirs_in < ours_in) { | ||
277 | SOCK_DEBUG(sk, "X.25: inbound throughput negotiated\n"); | ||
278 | new->throughput = (new->throughput & 0xf0) | theirs_in; | ||
279 | } | ||
280 | if (!ours_out || theirs_out < ours_out) { | ||
281 | SOCK_DEBUG(sk, | ||
282 | "X.25: outbound throughput negotiated\n"); | ||
283 | new->throughput = (new->throughput & 0x0f) | theirs_out; | ||
275 | } | 284 | } |
276 | } | 285 | } |
277 | 286 | ||