aboutsummaryrefslogtreecommitdiffstats
path: root/net/x25
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2011-07-01 05:43:13 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-01 19:11:16 -0400
commitfddc5f3e9164858cd9264a17580f9fc5ad948458 (patch)
tree8ac3da6561b74851304164af6e295a80f61e7665 /net/x25
parent89f0e4feafb64643b0f0aba9d89984362bac9739 (diff)
x25: Reduce switch/case indent
Make the case labels the same indent as the switch. git diff -w shows 80 column line reflowing. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/x25')
-rw-r--r--net/x25/af_x25.c471
-rw-r--r--net/x25/x25_dev.c44
-rw-r--r--net/x25/x25_in.c118
-rw-r--r--net/x25/x25_link.c87
-rw-r--r--net/x25/x25_subr.c78
5 files changed, 396 insertions, 402 deletions
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 4680b1e4c79c..d30615419b4d 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -237,21 +237,21 @@ static int x25_device_event(struct notifier_block *this, unsigned long event,
237#endif 237#endif
238 ) { 238 ) {
239 switch (event) { 239 switch (event) {
240 case NETDEV_UP: 240 case NETDEV_UP:
241 x25_link_device_up(dev); 241 x25_link_device_up(dev);
242 break; 242 break;
243 case NETDEV_GOING_DOWN: 243 case NETDEV_GOING_DOWN:
244 nb = x25_get_neigh(dev); 244 nb = x25_get_neigh(dev);
245 if (nb) { 245 if (nb) {
246 x25_terminate_link(nb); 246 x25_terminate_link(nb);
247 x25_neigh_put(nb); 247 x25_neigh_put(nb);
248 } 248 }
249 break; 249 break;
250 case NETDEV_DOWN: 250 case NETDEV_DOWN:
251 x25_kill_by_device(dev); 251 x25_kill_by_device(dev);
252 x25_route_device_down(dev); 252 x25_route_device_down(dev);
253 x25_link_device_down(dev); 253 x25_link_device_down(dev);
254 break; 254 break;
255 } 255 }
256 } 256 }
257 257
@@ -1336,256 +1336,253 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1336 int rc; 1336 int rc;
1337 1337
1338 switch (cmd) { 1338 switch (cmd) {
1339 case TIOCOUTQ: { 1339 case TIOCOUTQ: {
1340 int amount; 1340 int amount;
1341 1341
1342 amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk); 1342 amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk);
1343 if (amount < 0) 1343 if (amount < 0)
1344 amount = 0; 1344 amount = 0;
1345 rc = put_user(amount, (unsigned int __user *)argp); 1345 rc = put_user(amount, (unsigned int __user *)argp);
1346 break; 1346 break;
1347 } 1347 }
1348 1348
1349 case TIOCINQ: { 1349 case TIOCINQ: {
1350 struct sk_buff *skb; 1350 struct sk_buff *skb;
1351 int amount = 0; 1351 int amount = 0;
1352 /* 1352 /*
1353 * These two are safe on a single CPU system as 1353 * These two are safe on a single CPU system as
1354 * only user tasks fiddle here 1354 * only user tasks fiddle here
1355 */ 1355 */
1356 lock_sock(sk); 1356 lock_sock(sk);
1357 if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) 1357 if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL)
1358 amount = skb->len; 1358 amount = skb->len;
1359 release_sock(sk); 1359 release_sock(sk);
1360 rc = put_user(amount, (unsigned int __user *)argp); 1360 rc = put_user(amount, (unsigned int __user *)argp);
1361 break; 1361 break;
1362 } 1362 }
1363 1363
1364 case SIOCGSTAMP: 1364 case SIOCGSTAMP:
1365 rc = -EINVAL; 1365 rc = -EINVAL;
1366 if (sk) 1366 if (sk)
1367 rc = sock_get_timestamp(sk, 1367 rc = sock_get_timestamp(sk,
1368 (struct timeval __user *)argp); 1368 (struct timeval __user *)argp);
1369 break;
1370 case SIOCGSTAMPNS:
1371 rc = -EINVAL;
1372 if (sk)
1373 rc = sock_get_timestampns(sk,
1374 (struct timespec __user *)argp);
1375 break;
1376 case SIOCGIFADDR:
1377 case SIOCSIFADDR:
1378 case SIOCGIFDSTADDR:
1379 case SIOCSIFDSTADDR:
1380 case SIOCGIFBRDADDR:
1381 case SIOCSIFBRDADDR:
1382 case SIOCGIFNETMASK:
1383 case SIOCSIFNETMASK:
1384 case SIOCGIFMETRIC:
1385 case SIOCSIFMETRIC:
1386 rc = -EINVAL;
1387 break;
1388 case SIOCADDRT:
1389 case SIOCDELRT:
1390 rc = -EPERM;
1391 if (!capable(CAP_NET_ADMIN))
1369 break; 1392 break;
1370 case SIOCGSTAMPNS: 1393 rc = x25_route_ioctl(cmd, argp);
1371 rc = -EINVAL; 1394 break;
1372 if (sk) 1395 case SIOCX25GSUBSCRIP:
1373 rc = sock_get_timestampns(sk, 1396 rc = x25_subscr_ioctl(cmd, argp);
1374 (struct timespec __user *)argp); 1397 break;
1375 break; 1398 case SIOCX25SSUBSCRIP:
1376 case SIOCGIFADDR: 1399 rc = -EPERM;
1377 case SIOCSIFADDR: 1400 if (!capable(CAP_NET_ADMIN))
1378 case SIOCGIFDSTADDR:
1379 case SIOCSIFDSTADDR:
1380 case SIOCGIFBRDADDR:
1381 case SIOCSIFBRDADDR:
1382 case SIOCGIFNETMASK:
1383 case SIOCSIFNETMASK:
1384 case SIOCGIFMETRIC:
1385 case SIOCSIFMETRIC:
1386 rc = -EINVAL;
1387 break;
1388 case SIOCADDRT:
1389 case SIOCDELRT:
1390 rc = -EPERM;
1391 if (!capable(CAP_NET_ADMIN))
1392 break;
1393 rc = x25_route_ioctl(cmd, argp);
1394 break;
1395 case SIOCX25GSUBSCRIP:
1396 rc = x25_subscr_ioctl(cmd, argp);
1397 break;
1398 case SIOCX25SSUBSCRIP:
1399 rc = -EPERM;
1400 if (!capable(CAP_NET_ADMIN))
1401 break;
1402 rc = x25_subscr_ioctl(cmd, argp);
1403 break;
1404 case SIOCX25GFACILITIES: {
1405 lock_sock(sk);
1406 rc = copy_to_user(argp, &x25->facilities,
1407 sizeof(x25->facilities))
1408 ? -EFAULT : 0;
1409 release_sock(sk);
1410 break; 1401 break;
1411 } 1402 rc = x25_subscr_ioctl(cmd, argp);
1403 break;
1404 case SIOCX25GFACILITIES: {
1405 lock_sock(sk);
1406 rc = copy_to_user(argp, &x25->facilities,
1407 sizeof(x25->facilities))
1408 ? -EFAULT : 0;
1409 release_sock(sk);
1410 break;
1411 }
1412 1412
1413 case SIOCX25SFACILITIES: { 1413 case SIOCX25SFACILITIES: {
1414 struct x25_facilities facilities; 1414 struct x25_facilities facilities;
1415 rc = -EFAULT; 1415 rc = -EFAULT;
1416 if (copy_from_user(&facilities, argp, 1416 if (copy_from_user(&facilities, argp, sizeof(facilities)))
1417 sizeof(facilities))) 1417 break;
1418 break; 1418 rc = -EINVAL;
1419 rc = -EINVAL; 1419 lock_sock(sk);
1420 lock_sock(sk); 1420 if (sk->sk_state != TCP_LISTEN &&
1421 if (sk->sk_state != TCP_LISTEN && 1421 sk->sk_state != TCP_CLOSE)
1422 sk->sk_state != TCP_CLOSE) 1422 goto out_fac_release;
1423 goto out_fac_release; 1423 if (facilities.pacsize_in < X25_PS16 ||
1424 if (facilities.pacsize_in < X25_PS16 || 1424 facilities.pacsize_in > X25_PS4096)
1425 facilities.pacsize_in > X25_PS4096) 1425 goto out_fac_release;
1426 goto out_fac_release; 1426 if (facilities.pacsize_out < X25_PS16 ||
1427 if (facilities.pacsize_out < X25_PS16 || 1427 facilities.pacsize_out > X25_PS4096)
1428 facilities.pacsize_out > X25_PS4096) 1428 goto out_fac_release;
1429 goto out_fac_release; 1429 if (facilities.winsize_in < 1 ||
1430 if (facilities.winsize_in < 1 || 1430 facilities.winsize_in > 127)
1431 facilities.winsize_in > 127) 1431 goto out_fac_release;
1432 if (facilities.throughput) {
1433 int out = facilities.throughput & 0xf0;
1434 int in = facilities.throughput & 0x0f;
1435 if (!out)
1436 facilities.throughput |=
1437 X25_DEFAULT_THROUGHPUT << 4;
1438 else if (out < 0x30 || out > 0xD0)
1432 goto out_fac_release; 1439 goto out_fac_release;
1433 if (facilities.throughput) { 1440 if (!in)
1434 int out = facilities.throughput & 0xf0; 1441 facilities.throughput |=
1435 int in = facilities.throughput & 0x0f; 1442 X25_DEFAULT_THROUGHPUT;
1436 if (!out) 1443 else if (in < 0x03 || in > 0x0D)
1437 facilities.throughput |=
1438 X25_DEFAULT_THROUGHPUT << 4;
1439 else if (out < 0x30 || out > 0xD0)
1440 goto out_fac_release;
1441 if (!in)
1442 facilities.throughput |=
1443 X25_DEFAULT_THROUGHPUT;
1444 else if (in < 0x03 || in > 0x0D)
1445 goto out_fac_release;
1446 }
1447 if (facilities.reverse &&
1448 (facilities.reverse & 0x81) != 0x81)
1449 goto out_fac_release; 1444 goto out_fac_release;
1450 x25->facilities = facilities;
1451 rc = 0;
1452out_fac_release:
1453 release_sock(sk);
1454 break;
1455 }
1456
1457 case SIOCX25GDTEFACILITIES: {
1458 lock_sock(sk);
1459 rc = copy_to_user(argp, &x25->dte_facilities,
1460 sizeof(x25->dte_facilities));
1461 release_sock(sk);
1462 if (rc)
1463 rc = -EFAULT;
1464 break;
1465 } 1445 }
1446 if (facilities.reverse &&
1447 (facilities.reverse & 0x81) != 0x81)
1448 goto out_fac_release;
1449 x25->facilities = facilities;
1450 rc = 0;
1451out_fac_release:
1452 release_sock(sk);
1453 break;
1454 }
1466 1455
1467 case SIOCX25SDTEFACILITIES: { 1456 case SIOCX25GDTEFACILITIES: {
1468 struct x25_dte_facilities dtefacs; 1457 lock_sock(sk);
1458 rc = copy_to_user(argp, &x25->dte_facilities,
1459 sizeof(x25->dte_facilities));
1460 release_sock(sk);
1461 if (rc)
1469 rc = -EFAULT; 1462 rc = -EFAULT;
1470 if (copy_from_user(&dtefacs, argp, sizeof(dtefacs))) 1463 break;
1471 break; 1464 }
1472 rc = -EINVAL;
1473 lock_sock(sk);
1474 if (sk->sk_state != TCP_LISTEN &&
1475 sk->sk_state != TCP_CLOSE)
1476 goto out_dtefac_release;
1477 if (dtefacs.calling_len > X25_MAX_AE_LEN)
1478 goto out_dtefac_release;
1479 if (dtefacs.calling_ae == NULL)
1480 goto out_dtefac_release;
1481 if (dtefacs.called_len > X25_MAX_AE_LEN)
1482 goto out_dtefac_release;
1483 if (dtefacs.called_ae == NULL)
1484 goto out_dtefac_release;
1485 x25->dte_facilities = dtefacs;
1486 rc = 0;
1487out_dtefac_release:
1488 release_sock(sk);
1489 break;
1490 }
1491 1465
1492 case SIOCX25GCALLUSERDATA: { 1466 case SIOCX25SDTEFACILITIES: {
1493 lock_sock(sk); 1467 struct x25_dte_facilities dtefacs;
1494 rc = copy_to_user(argp, &x25->calluserdata, 1468 rc = -EFAULT;
1495 sizeof(x25->calluserdata)) 1469 if (copy_from_user(&dtefacs, argp, sizeof(dtefacs)))
1496 ? -EFAULT : 0;
1497 release_sock(sk);
1498 break; 1470 break;
1499 } 1471 rc = -EINVAL;
1472 lock_sock(sk);
1473 if (sk->sk_state != TCP_LISTEN &&
1474 sk->sk_state != TCP_CLOSE)
1475 goto out_dtefac_release;
1476 if (dtefacs.calling_len > X25_MAX_AE_LEN)
1477 goto out_dtefac_release;
1478 if (dtefacs.calling_ae == NULL)
1479 goto out_dtefac_release;
1480 if (dtefacs.called_len > X25_MAX_AE_LEN)
1481 goto out_dtefac_release;
1482 if (dtefacs.called_ae == NULL)
1483 goto out_dtefac_release;
1484 x25->dte_facilities = dtefacs;
1485 rc = 0;
1486out_dtefac_release:
1487 release_sock(sk);
1488 break;
1489 }
1500 1490
1501 case SIOCX25SCALLUSERDATA: { 1491 case SIOCX25GCALLUSERDATA: {
1502 struct x25_calluserdata calluserdata; 1492 lock_sock(sk);
1493 rc = copy_to_user(argp, &x25->calluserdata,
1494 sizeof(x25->calluserdata))
1495 ? -EFAULT : 0;
1496 release_sock(sk);
1497 break;
1498 }
1503 1499
1504 rc = -EFAULT; 1500 case SIOCX25SCALLUSERDATA: {
1505 if (copy_from_user(&calluserdata, argp, 1501 struct x25_calluserdata calluserdata;
1506 sizeof(calluserdata)))
1507 break;
1508 rc = -EINVAL;
1509 if (calluserdata.cudlength > X25_MAX_CUD_LEN)
1510 break;
1511 lock_sock(sk);
1512 x25->calluserdata = calluserdata;
1513 release_sock(sk);
1514 rc = 0;
1515 break;
1516 }
1517 1502
1518 case SIOCX25GCAUSEDIAG: { 1503 rc = -EFAULT;
1519 lock_sock(sk); 1504 if (copy_from_user(&calluserdata, argp, sizeof(calluserdata)))
1520 rc = copy_to_user(argp, &x25->causediag,
1521 sizeof(x25->causediag))
1522 ? -EFAULT : 0;
1523 release_sock(sk);
1524 break; 1505 break;
1525 } 1506 rc = -EINVAL;
1507 if (calluserdata.cudlength > X25_MAX_CUD_LEN)
1508 break;
1509 lock_sock(sk);
1510 x25->calluserdata = calluserdata;
1511 release_sock(sk);
1512 rc = 0;
1513 break;
1514 }
1526 1515
1527 case SIOCX25SCAUSEDIAG: { 1516 case SIOCX25GCAUSEDIAG: {
1528 struct x25_causediag causediag; 1517 lock_sock(sk);
1529 rc = -EFAULT; 1518 rc = copy_to_user(argp, &x25->causediag, sizeof(x25->causediag))
1530 if (copy_from_user(&causediag, argp, sizeof(causediag))) 1519 ? -EFAULT : 0;
1531 break; 1520 release_sock(sk);
1532 lock_sock(sk); 1521 break;
1533 x25->causediag = causediag; 1522 }
1534 release_sock(sk); 1523
1535 rc = 0; 1524 case SIOCX25SCAUSEDIAG: {
1525 struct x25_causediag causediag;
1526 rc = -EFAULT;
1527 if (copy_from_user(&causediag, argp, sizeof(causediag)))
1536 break; 1528 break;
1529 lock_sock(sk);
1530 x25->causediag = causediag;
1531 release_sock(sk);
1532 rc = 0;
1533 break;
1537 1534
1538 } 1535 }
1539 1536
1540 case SIOCX25SCUDMATCHLEN: { 1537 case SIOCX25SCUDMATCHLEN: {
1541 struct x25_subaddr sub_addr; 1538 struct x25_subaddr sub_addr;
1542 rc = -EINVAL; 1539 rc = -EINVAL;
1543 lock_sock(sk); 1540 lock_sock(sk);
1544 if(sk->sk_state != TCP_CLOSE) 1541 if(sk->sk_state != TCP_CLOSE)
1545 goto out_cud_release; 1542 goto out_cud_release;
1546 rc = -EFAULT; 1543 rc = -EFAULT;
1547 if (copy_from_user(&sub_addr, argp, 1544 if (copy_from_user(&sub_addr, argp,
1548 sizeof(sub_addr))) 1545 sizeof(sub_addr)))
1549 goto out_cud_release; 1546 goto out_cud_release;
1550 rc = -EINVAL; 1547 rc = -EINVAL;
1551 if(sub_addr.cudmatchlength > X25_MAX_CUD_LEN) 1548 if (sub_addr.cudmatchlength > X25_MAX_CUD_LEN)
1552 goto out_cud_release; 1549 goto out_cud_release;
1553 x25->cudmatchlength = sub_addr.cudmatchlength; 1550 x25->cudmatchlength = sub_addr.cudmatchlength;
1554 rc = 0; 1551 rc = 0;
1555out_cud_release: 1552out_cud_release:
1556 release_sock(sk); 1553 release_sock(sk);
1557 break; 1554 break;
1558 } 1555 }
1559 1556
1560 case SIOCX25CALLACCPTAPPRV: { 1557 case SIOCX25CALLACCPTAPPRV: {
1561 rc = -EINVAL; 1558 rc = -EINVAL;
1562 lock_sock(sk); 1559 lock_sock(sk);
1563 if (sk->sk_state != TCP_CLOSE) 1560 if (sk->sk_state != TCP_CLOSE)
1564 break;
1565 clear_bit(X25_ACCPT_APPRV_FLAG, &x25->flags);
1566 release_sock(sk);
1567 rc = 0;
1568 break; 1561 break;
1569 } 1562 clear_bit(X25_ACCPT_APPRV_FLAG, &x25->flags);
1563 release_sock(sk);
1564 rc = 0;
1565 break;
1566 }
1570 1567
1571 case SIOCX25SENDCALLACCPT: { 1568 case SIOCX25SENDCALLACCPT: {
1572 rc = -EINVAL; 1569 rc = -EINVAL;
1573 lock_sock(sk); 1570 lock_sock(sk);
1574 if (sk->sk_state != TCP_ESTABLISHED) 1571 if (sk->sk_state != TCP_ESTABLISHED)
1575 break;
1576 /* must call accptapprv above */
1577 if (test_bit(X25_ACCPT_APPRV_FLAG, &x25->flags))
1578 break;
1579 x25_write_internal(sk, X25_CALL_ACCEPTED);
1580 x25->state = X25_STATE_3;
1581 release_sock(sk);
1582 rc = 0;
1583 break; 1572 break;
1584 } 1573 /* must call accptapprv above */
1585 1574 if (test_bit(X25_ACCPT_APPRV_FLAG, &x25->flags))
1586 default:
1587 rc = -ENOIOCTLCMD;
1588 break; 1575 break;
1576 x25_write_internal(sk, X25_CALL_ACCEPTED);
1577 x25->state = X25_STATE_3;
1578 release_sock(sk);
1579 rc = 0;
1580 break;
1581 }
1582
1583 default:
1584 rc = -ENOIOCTLCMD;
1585 break;
1589 } 1586 }
1590 1587
1591 return rc; 1588 return rc;
diff --git a/net/x25/x25_dev.c b/net/x25/x25_dev.c
index 9005f6daeab5..e547ca1578c3 100644
--- a/net/x25/x25_dev.c
+++ b/net/x25/x25_dev.c
@@ -146,21 +146,21 @@ void x25_establish_link(struct x25_neigh *nb)
146 unsigned char *ptr; 146 unsigned char *ptr;
147 147
148 switch (nb->dev->type) { 148 switch (nb->dev->type) {
149 case ARPHRD_X25: 149 case ARPHRD_X25:
150 if ((skb = alloc_skb(1, GFP_ATOMIC)) == NULL) { 150 if ((skb = alloc_skb(1, GFP_ATOMIC)) == NULL) {
151 printk(KERN_ERR "x25_dev: out of memory\n"); 151 printk(KERN_ERR "x25_dev: out of memory\n");
152 return; 152 return;
153 } 153 }
154 ptr = skb_put(skb, 1); 154 ptr = skb_put(skb, 1);
155 *ptr = X25_IFACE_CONNECT; 155 *ptr = X25_IFACE_CONNECT;
156 break; 156 break;
157 157
158#if defined(CONFIG_LLC) || defined(CONFIG_LLC_MODULE) 158#if defined(CONFIG_LLC) || defined(CONFIG_LLC_MODULE)
159 case ARPHRD_ETHER: 159 case ARPHRD_ETHER:
160 return; 160 return;
161#endif 161#endif
162 default: 162 default:
163 return; 163 return;
164 } 164 }
165 165
166 skb->protocol = htons(ETH_P_X25); 166 skb->protocol = htons(ETH_P_X25);
@@ -202,19 +202,19 @@ void x25_send_frame(struct sk_buff *skb, struct x25_neigh *nb)
202 skb_reset_network_header(skb); 202 skb_reset_network_header(skb);
203 203
204 switch (nb->dev->type) { 204 switch (nb->dev->type) {
205 case ARPHRD_X25: 205 case ARPHRD_X25:
206 dptr = skb_push(skb, 1); 206 dptr = skb_push(skb, 1);
207 *dptr = X25_IFACE_DATA; 207 *dptr = X25_IFACE_DATA;
208 break; 208 break;
209 209
210#if defined(CONFIG_LLC) || defined(CONFIG_LLC_MODULE) 210#if defined(CONFIG_LLC) || defined(CONFIG_LLC_MODULE)
211 case ARPHRD_ETHER: 211 case ARPHRD_ETHER:
212 kfree_skb(skb); 212 kfree_skb(skb);
213 return; 213 return;
214#endif 214#endif
215 default: 215 default:
216 kfree_skb(skb); 216 kfree_skb(skb);
217 return; 217 return;
218 } 218 }
219 219
220 skb->protocol = htons(ETH_P_X25); 220 skb->protocol = htons(ETH_P_X25);
diff --git a/net/x25/x25_in.c b/net/x25/x25_in.c
index 15de65f04719..0b073b51b183 100644
--- a/net/x25/x25_in.c
+++ b/net/x25/x25_in.c
@@ -94,55 +94,55 @@ static int x25_state1_machine(struct sock *sk, struct sk_buff *skb, int frametyp
94 struct x25_sock *x25 = x25_sk(sk); 94 struct x25_sock *x25 = x25_sk(sk);
95 95
96 switch (frametype) { 96 switch (frametype) {
97 case X25_CALL_ACCEPTED: { 97 case X25_CALL_ACCEPTED: {
98 98
99 x25_stop_timer(sk); 99 x25_stop_timer(sk);
100 x25->condition = 0x00; 100 x25->condition = 0x00;
101 x25->vs = 0; 101 x25->vs = 0;
102 x25->va = 0; 102 x25->va = 0;
103 x25->vr = 0; 103 x25->vr = 0;
104 x25->vl = 0; 104 x25->vl = 0;
105 x25->state = X25_STATE_3; 105 x25->state = X25_STATE_3;
106 sk->sk_state = TCP_ESTABLISHED; 106 sk->sk_state = TCP_ESTABLISHED;
107 /* 107 /*
108 * Parse the data in the frame. 108 * Parse the data in the frame.
109 */ 109 */
110 skb_pull(skb, X25_STD_MIN_LEN); 110 skb_pull(skb, X25_STD_MIN_LEN);
111 111
112 len = x25_parse_address_block(skb, &source_addr, 112 len = x25_parse_address_block(skb, &source_addr,
113 &dest_addr); 113 &dest_addr);
114 if (len > 0) 114 if (len > 0)
115 skb_pull(skb, len); 115 skb_pull(skb, len);
116 else if (len < 0) 116 else if (len < 0)
117 goto out_clear; 117 goto out_clear;
118 118
119 len = x25_parse_facilities(skb, &x25->facilities, 119 len = x25_parse_facilities(skb, &x25->facilities,
120 &x25->dte_facilities, 120 &x25->dte_facilities,
121 &x25->vc_facil_mask); 121 &x25->vc_facil_mask);
122 if (len > 0) 122 if (len > 0)
123 skb_pull(skb, len); 123 skb_pull(skb, len);
124 else if (len < 0) 124 else if (len < 0)
125 goto out_clear; 125 goto out_clear;
126 /* 126 /*
127 * Copy any Call User Data. 127 * Copy any Call User Data.
128 */ 128 */
129 if (skb->len > 0) { 129 if (skb->len > 0) {
130 skb_copy_from_linear_data(skb, 130 skb_copy_from_linear_data(skb,
131 x25->calluserdata.cuddata, 131 x25->calluserdata.cuddata,
132 skb->len); 132 skb->len);
133 x25->calluserdata.cudlength = skb->len; 133 x25->calluserdata.cudlength = skb->len;
134 }
135 if (!sock_flag(sk, SOCK_DEAD))
136 sk->sk_state_change(sk);
137 break;
138 } 134 }
139 case X25_CLEAR_REQUEST: 135 if (!sock_flag(sk, SOCK_DEAD))
140 x25_write_internal(sk, X25_CLEAR_CONFIRMATION); 136 sk->sk_state_change(sk);
141 x25_disconnect(sk, ECONNREFUSED, skb->data[3], skb->data[4]); 137 break;
142 break; 138 }
139 case X25_CLEAR_REQUEST:
140 x25_write_internal(sk, X25_CLEAR_CONFIRMATION);
141 x25_disconnect(sk, ECONNREFUSED, skb->data[3], skb->data[4]);
142 break;
143 143
144 default: 144 default:
145 break; 145 break;
146 } 146 }
147 147
148 return 0; 148 return 0;
@@ -354,18 +354,18 @@ int x25_process_rx_frame(struct sock *sk, struct sk_buff *skb)
354 frametype = x25_decode(sk, skb, &ns, &nr, &q, &d, &m); 354 frametype = x25_decode(sk, skb, &ns, &nr, &q, &d, &m);
355 355
356 switch (x25->state) { 356 switch (x25->state) {
357 case X25_STATE_1: 357 case X25_STATE_1:
358 queued = x25_state1_machine(sk, skb, frametype); 358 queued = x25_state1_machine(sk, skb, frametype);
359 break; 359 break;
360 case X25_STATE_2: 360 case X25_STATE_2:
361 queued = x25_state2_machine(sk, skb, frametype); 361 queued = x25_state2_machine(sk, skb, frametype);
362 break; 362 break;
363 case X25_STATE_3: 363 case X25_STATE_3:
364 queued = x25_state3_machine(sk, skb, frametype, ns, nr, q, d, m); 364 queued = x25_state3_machine(sk, skb, frametype, ns, nr, q, d, m);
365 break; 365 break;
366 case X25_STATE_4: 366 case X25_STATE_4:
367 queued = x25_state4_machine(sk, skb, frametype); 367 queued = x25_state4_machine(sk, skb, frametype);
368 break; 368 break;
369 } 369 }
370 370
371 x25_kick(sk); 371 x25_kick(sk);
diff --git a/net/x25/x25_link.c b/net/x25/x25_link.c
index 21306928d47f..037958ff8eed 100644
--- a/net/x25/x25_link.c
+++ b/net/x25/x25_link.c
@@ -76,30 +76,29 @@ void x25_link_control(struct sk_buff *skb, struct x25_neigh *nb,
76 int confirm; 76 int confirm;
77 77
78 switch (frametype) { 78 switch (frametype) {
79 case X25_RESTART_REQUEST: 79 case X25_RESTART_REQUEST:
80 confirm = !x25_t20timer_pending(nb); 80 confirm = !x25_t20timer_pending(nb);
81 x25_stop_t20timer(nb); 81 x25_stop_t20timer(nb);
82 nb->state = X25_LINK_STATE_3; 82 nb->state = X25_LINK_STATE_3;
83 if (confirm) 83 if (confirm)
84 x25_transmit_restart_confirmation(nb); 84 x25_transmit_restart_confirmation(nb);
85 break; 85 break;
86 86
87 case X25_RESTART_CONFIRMATION: 87 case X25_RESTART_CONFIRMATION:
88 x25_stop_t20timer(nb); 88 x25_stop_t20timer(nb);
89 nb->state = X25_LINK_STATE_3; 89 nb->state = X25_LINK_STATE_3;
90 break; 90 break;
91 91
92 case X25_DIAGNOSTIC: 92 case X25_DIAGNOSTIC:
93 printk(KERN_WARNING "x25: diagnostic #%d - " 93 printk(KERN_WARNING "x25: diagnostic #%d - %02X %02X %02X\n",
94 "%02X %02X %02X\n", 94 skb->data[3], skb->data[4],
95 skb->data[3], skb->data[4], 95 skb->data[5], skb->data[6]);
96 skb->data[5], skb->data[6]); 96 break;
97 break; 97
98 98 default:
99 default: 99 printk(KERN_WARNING "x25: received unknown %02X with LCI 000\n",
100 printk(KERN_WARNING "x25: received unknown %02X " 100 frametype);
101 "with LCI 000\n", frametype); 101 break;
102 break;
103 } 102 }
104 103
105 if (nb->state == X25_LINK_STATE_3) 104 if (nb->state == X25_LINK_STATE_3)
@@ -193,18 +192,18 @@ void x25_transmit_clear_request(struct x25_neigh *nb, unsigned int lci,
193void x25_transmit_link(struct sk_buff *skb, struct x25_neigh *nb) 192void x25_transmit_link(struct sk_buff *skb, struct x25_neigh *nb)
194{ 193{
195 switch (nb->state) { 194 switch (nb->state) {
196 case X25_LINK_STATE_0: 195 case X25_LINK_STATE_0:
197 skb_queue_tail(&nb->queue, skb); 196 skb_queue_tail(&nb->queue, skb);
198 nb->state = X25_LINK_STATE_1; 197 nb->state = X25_LINK_STATE_1;
199 x25_establish_link(nb); 198 x25_establish_link(nb);
200 break; 199 break;
201 case X25_LINK_STATE_1: 200 case X25_LINK_STATE_1:
202 case X25_LINK_STATE_2: 201 case X25_LINK_STATE_2:
203 skb_queue_tail(&nb->queue, skb); 202 skb_queue_tail(&nb->queue, skb);
204 break; 203 break;
205 case X25_LINK_STATE_3: 204 case X25_LINK_STATE_3:
206 x25_send_frame(skb, nb); 205 x25_send_frame(skb, nb);
207 break; 206 break;
208 } 207 }
209} 208}
210 209
@@ -214,14 +213,14 @@ void x25_transmit_link(struct sk_buff *skb, struct x25_neigh *nb)
214void x25_link_established(struct x25_neigh *nb) 213void x25_link_established(struct x25_neigh *nb)
215{ 214{
216 switch (nb->state) { 215 switch (nb->state) {
217 case X25_LINK_STATE_0: 216 case X25_LINK_STATE_0:
218 nb->state = X25_LINK_STATE_2; 217 nb->state = X25_LINK_STATE_2;
219 break; 218 break;
220 case X25_LINK_STATE_1: 219 case X25_LINK_STATE_1:
221 x25_transmit_restart_request(nb); 220 x25_transmit_restart_request(nb);
222 nb->state = X25_LINK_STATE_2; 221 nb->state = X25_LINK_STATE_2;
223 x25_start_t20timer(nb); 222 x25_start_t20timer(nb);
224 break; 223 break;
225 } 224 }
226} 225}
227 226
diff --git a/net/x25/x25_subr.c b/net/x25/x25_subr.c
index dc20cf12f39b..24a342ebc7f5 100644
--- a/net/x25/x25_subr.c
+++ b/net/x25/x25_subr.c
@@ -126,32 +126,30 @@ void x25_write_internal(struct sock *sk, int frametype)
126 * Adjust frame size. 126 * Adjust frame size.
127 */ 127 */
128 switch (frametype) { 128 switch (frametype) {
129 case X25_CALL_REQUEST: 129 case X25_CALL_REQUEST:
130 len += 1 + X25_ADDR_LEN + X25_MAX_FAC_LEN + 130 len += 1 + X25_ADDR_LEN + X25_MAX_FAC_LEN + X25_MAX_CUD_LEN;
131 X25_MAX_CUD_LEN; 131 break;
132 break; 132 case X25_CALL_ACCEPTED: /* fast sel with no restr on resp */
133 case X25_CALL_ACCEPTED: /* fast sel with no restr on resp */ 133 if (x25->facilities.reverse & 0x80) {
134 if(x25->facilities.reverse & 0x80) { 134 len += 1 + X25_MAX_FAC_LEN + X25_MAX_CUD_LEN;
135 len += 1 + X25_MAX_FAC_LEN + X25_MAX_CUD_LEN; 135 } else {
136 } else { 136 len += 1 + X25_MAX_FAC_LEN;
137 len += 1 + X25_MAX_FAC_LEN; 137 }
138 } 138 break;
139 break; 139 case X25_CLEAR_REQUEST:
140 case X25_CLEAR_REQUEST: 140 case X25_RESET_REQUEST:
141 case X25_RESET_REQUEST: 141 len += 2;
142 len += 2; 142 break;
143 break; 143 case X25_RR:
144 case X25_RR: 144 case X25_RNR:
145 case X25_RNR: 145 case X25_REJ:
146 case X25_REJ: 146 case X25_CLEAR_CONFIRMATION:
147 case X25_CLEAR_CONFIRMATION: 147 case X25_INTERRUPT_CONFIRMATION:
148 case X25_INTERRUPT_CONFIRMATION: 148 case X25_RESET_CONFIRMATION:
149 case X25_RESET_CONFIRMATION: 149 break;
150 break; 150 default:
151 default: 151 printk(KERN_ERR "X.25: invalid frame type %02X\n", frametype);
152 printk(KERN_ERR "X.25: invalid frame type %02X\n", 152 return;
153 frametype);
154 return;
155 } 153 }
156 154
157 if ((skb = alloc_skb(len, GFP_ATOMIC)) == NULL) 155 if ((skb = alloc_skb(len, GFP_ATOMIC)) == NULL)
@@ -276,20 +274,20 @@ int x25_decode(struct sock *sk, struct sk_buff *skb, int *ns, int *nr, int *q,
276 *ns = *nr = *q = *d = *m = 0; 274 *ns = *nr = *q = *d = *m = 0;
277 275
278 switch (frame[2]) { 276 switch (frame[2]) {
279 case X25_CALL_REQUEST: 277 case X25_CALL_REQUEST:
280 case X25_CALL_ACCEPTED: 278 case X25_CALL_ACCEPTED:
281 case X25_CLEAR_REQUEST: 279 case X25_CLEAR_REQUEST:
282 case X25_CLEAR_CONFIRMATION: 280 case X25_CLEAR_CONFIRMATION:
283 case X25_INTERRUPT: 281 case X25_INTERRUPT:
284 case X25_INTERRUPT_CONFIRMATION: 282 case X25_INTERRUPT_CONFIRMATION:
285 case X25_RESET_REQUEST: 283 case X25_RESET_REQUEST:
286 case X25_RESET_CONFIRMATION: 284 case X25_RESET_CONFIRMATION:
287 case X25_RESTART_REQUEST: 285 case X25_RESTART_REQUEST:
288 case X25_RESTART_CONFIRMATION: 286 case X25_RESTART_CONFIRMATION:
289 case X25_REGISTRATION_REQUEST: 287 case X25_REGISTRATION_REQUEST:
290 case X25_REGISTRATION_CONFIRMATION: 288 case X25_REGISTRATION_CONFIRMATION:
291 case X25_DIAGNOSTIC: 289 case X25_DIAGNOSTIC:
292 return frame[2]; 290 return frame[2];
293 } 291 }
294 292
295 if (x25->neighbour->extended) { 293 if (x25->neighbour->extended) {