From: Andrew Morton Signed-off-by: Shaun Pereira Acked-by: Andrew Hendry Signed-off-by: Andrew Morton --- include/net/x25.h | 10 ++++--- net/x25/af_x25.c | 26 +++++++++--------- net/x25/x25_facilities.c | 52 +++++++++++++++---------------------- net/x25/x25_subr.c | 6 ++-- 4 files changed, 46 insertions(+), 48 deletions(-) diff -puN include/net/x25.h~x25-allow-itu-t-dte-facilities-for-x25-tidy include/net/x25.h --- devel/include/net/x25.h~x25-allow-itu-t-dte-facilities-for-x25-tidy 2006-02-17 00:41:07.000000000 -0800 +++ devel-akpm/include/net/x25.h 2006-02-17 00:41:07.000000000 -0800 @@ -189,9 +189,13 @@ extern void x25_establish_link(struct x2 extern void x25_terminate_link(struct x25_neigh *); /* x25_facilities.c */ -extern int x25_parse_facilities(struct sk_buff *, struct x25_facilities *, struct x25_dte_facilities *, unsigned long *); -extern int x25_create_facilities(unsigned char *, struct x25_facilities *, struct x25_dte_facilities *, unsigned long); -extern int x25_negotiate_facilities(struct sk_buff *, struct sock *, struct x25_facilities *, struct x25_dte_facilities *); +extern int x25_parse_facilities(struct sk_buff *, struct x25_facilities *, + struct x25_dte_facilities *, unsigned long *); +extern int x25_create_facilities(unsigned char *, struct x25_facilities *, + struct x25_dte_facilities *, unsigned long); +extern int x25_negotiate_facilities(struct sk_buff *, struct sock *, + struct x25_facilities *, + struct x25_dte_facilities *); extern void x25_limit_facilities(struct x25_facilities *, struct x25_neigh *); /* x25_in.c */ diff -puN net/x25/af_x25.c~x25-allow-itu-t-dte-facilities-for-x25-tidy net/x25/af_x25.c --- devel/net/x25/af_x25.c~x25-allow-itu-t-dte-facilities-for-x25-tidy 2006-02-17 00:41:07.000000000 -0800 +++ devel-akpm/net/x25/af_x25.c 2006-02-17 00:41:07.000000000 -0800 @@ -528,9 +528,9 @@ static int x25_create(struct socket *soc x25->dte_facilities.calling_len = 0; x25->dte_facilities.called_len = 0; memset(x25->dte_facilities.called_ae, '\0', - sizeof(x25->dte_facilities.called_ae)); + sizeof(x25->dte_facilities.called_ae)); memset(x25->dte_facilities.calling_ae, '\0', - sizeof(x25->dte_facilities.calling_ae)); + sizeof(x25->dte_facilities.calling_ae)); rc = 0; out: @@ -885,8 +885,8 @@ int x25_rx_call_request(struct sk_buff * /* * Try to reach a compromise on the requested facilities. */ - if ((len = x25_negotiate_facilities(skb, sk, &facilities, - &dte_facilities)) == -1) + len = x25_negotiate_facilities(skb, sk, &facilities, &dte_facilities); + if (len == -1) goto out_sock_put; /* @@ -1331,7 +1331,9 @@ static int x25_ioctl(struct socket *sock case SIOCX25GDTEFACILITIES: { rc = copy_to_user(argp, &x25->dte_facilities, - sizeof(x25->dte_facilities)) ? -EFAULT : 0; + sizeof(x25->dte_facilities)); + if (rc) + rc = -EFAULT; break; } @@ -1339,19 +1341,19 @@ static int x25_ioctl(struct socket *sock struct x25_dte_facilities dtefacs; rc = -EFAULT; if (copy_from_user(&dtefacs, argp, sizeof(dtefacs))) - break; + break; rc = -EINVAL; if (sk->sk_state != TCP_LISTEN && - sk->sk_state != TCP_CLOSE) - break; + sk->sk_state != TCP_CLOSE) + break; if (dtefacs.calling_len > X25_MAX_AE_LEN) - break; + break; if (dtefacs.calling_ae == NULL) - break; + break; if (dtefacs.called_len > X25_MAX_AE_LEN) - break; + break; if (dtefacs.called_ae == NULL) - break; + break; x25->dte_facilities = dtefacs; rc = 0; break; diff -puN net/x25/x25_facilities.c~x25-allow-itu-t-dte-facilities-for-x25-tidy net/x25/x25_facilities.c --- devel/net/x25/x25_facilities.c~x25-allow-itu-t-dte-facilities-for-x25-tidy 2006-02-17 00:41:07.000000000 -0800 +++ devel-akpm/net/x25/x25_facilities.c 2006-02-17 00:41:07.000000000 -0800 @@ -31,21 +31,20 @@ * Parse a set of facilities into the facilities structures. Unrecognised * facilities are written to the debug log file. */ -int x25_parse_facilities(struct sk_buff *skb, - struct x25_facilities *facilities, - struct x25_dte_facilities *dte_facs, - unsigned long *vc_fac_mask) +int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities, + struct x25_dte_facilities *dte_facs, unsigned long *vc_fac_mask) { unsigned char *p = skb->data; unsigned int len = *p++; *vc_fac_mask = 0; - /* The kernel knows which facilities were set on an incoming call - * but currently this information is not available to userspace. - * Here we give userspace who read incoming call facilities - * 0 length to indicate it wasn't set. - */ + /* + * The kernel knows which facilities were set on an incoming call but + * currently this information is not available to userspace. Here we + * give userspace who read incoming call facilities 0 length to indicate + * it wasn't set. + */ dte_facs->calling_len = 0; dte_facs->called_len = 0; memset(dte_facs->called_ae, '\0', sizeof(dte_facs->called_ae)); @@ -85,10 +84,8 @@ int x25_parse_facilities(struct sk_buff facilities->throughput = p[1]; *vc_fac_mask |= X25_MASK_THROUGHPUT; break; - case X25_MARKER: break; - default: printk(KERN_DEBUG "X.25: unknown facility " "%02X, value %02X\n", @@ -127,32 +124,30 @@ int x25_parse_facilities(struct sk_buff len -= 4; break; case X25_FAC_CLASS_D: - switch (*p) { + switch (*p) { case X25_FAC_CALLING_AE: if (p[1] > X25_MAX_DTE_FACIL_LEN) - break; + break; dte_facs->calling_len = p[2]; memcpy(dte_facs->calling_ae, &p[3], p[1] - 1); *vc_fac_mask |= X25_MASK_CALLING_AE; break; - case X25_FAC_CALLED_AE: if (p[1] > X25_MAX_DTE_FACIL_LEN) - break; + break; dte_facs->called_len = p[2]; memcpy(dte_facs->called_ae, &p[3], p[1] - 1); *vc_fac_mask |= X25_MASK_CALLED_AE; break; - default: printk(KERN_DEBUG "X.25: unknown facility %02X," - "length %d, values %02X, %02X, %02X, %02X\n", - p[0], p[1], p[2], p[3], p[4], p[5]); + "length %d, values %02X, %02X, " + "%02X, %02X\n", + p[0], p[1], p[2], p[3], p[4], p[5]); break; } - len -= p[1] + 2; - p += p[1] + 2; + p += p[1] + 2; break; } } @@ -164,9 +159,8 @@ int x25_parse_facilities(struct sk_buff * Create a set of facilities. */ int x25_create_facilities(unsigned char *buffer, - struct x25_facilities *facilities, - struct x25_dte_facilities *dte_facs, - unsigned long facil_mask) + struct x25_facilities *facilities, + struct x25_dte_facilities *dte_facs, unsigned long facil_mask) { unsigned char *p = buffer + 1; int len; @@ -205,21 +199,20 @@ int x25_create_facilities(unsigned char *p++ = facilities->winsize_out ? : facilities->winsize_in; } - if ((facil_mask & X25_MASK_CALLING_AE) || - (facil_mask & X25_MASK_CALLED_AE)) { + if (facil_mask & (X25_MASK_CALLING_AE|X25_MASK_CALLED_AE)) { *p++ = X25_MARKER; *p++ = X25_DTE_SERVICES; } if (dte_facs->calling_len && (facil_mask & X25_MASK_CALLING_AE)) { unsigned bytecount = (dte_facs->calling_len % 2) ? - dte_facs->calling_len / 2 + 1 : - dte_facs->calling_len / 2; + dte_facs->calling_len / 2 + 1 : + dte_facs->calling_len / 2; *p++ = X25_FAC_CALLING_AE; *p++ = 1 + bytecount; *p++ = dte_facs->calling_len; memcpy(p, dte_facs->calling_ae, bytecount); - p+=bytecount; + p += bytecount; } if (dte_facs->called_len && (facil_mask & X25_MASK_CALLED_AE)) { @@ -245,8 +238,7 @@ int x25_create_facilities(unsigned char * The only real problem is with reverse charging. */ int x25_negotiate_facilities(struct sk_buff *skb, struct sock *sk, - struct x25_facilities *new, - struct x25_dte_facilities *dte) + struct x25_facilities *new, struct x25_dte_facilities *dte) { struct x25_sock *x25 = x25_sk(sk); struct x25_facilities *ours = &x25->facilities; diff -puN net/x25/x25_subr.c~x25-allow-itu-t-dte-facilities-for-x25-tidy net/x25/x25_subr.c --- devel/net/x25/x25_subr.c~x25-allow-itu-t-dte-facilities-for-x25-tidy 2006-02-17 00:41:07.000000000 -0800 +++ devel-akpm/net/x25/x25_subr.c 2006-02-17 00:41:07.000000000 -0800 @@ -190,9 +190,9 @@ void x25_write_internal(struct sock *sk, dptr = skb_put(skb, len); memcpy(dptr, addresses, len); len = x25_create_facilities(facilities, - &x25->facilities, - &x25->dte_facilities, - x25->neighbour->global_facil_mask); + &x25->facilities, + &x25->dte_facilities, + x25->neighbour->global_facil_mask); dptr = skb_put(skb, len); memcpy(dptr, facilities, len); dptr = skb_put(skb, x25->calluserdata.cudlength); _