forked from luck/tmp_suning_uos_patched
[PPPOE]: Introduce pppoe_hdr()
For consistency with all the other skb->nh.raw accessors. Also do some really obvious simplifications in pppoe_recvmsg, well the kfree_skb one is not so obvious, but free() and kfree() have the same behaviour (hint :-) ). Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
37e6636669
commit
797659fb4a
@ -347,7 +347,7 @@ static int pppoe_rcv_core(struct sock *sk, struct sk_buff *skb)
|
|||||||
struct pppox_sock *relay_po = NULL;
|
struct pppox_sock *relay_po = NULL;
|
||||||
|
|
||||||
if (sk->sk_state & PPPOX_BOUND) {
|
if (sk->sk_state & PPPOX_BOUND) {
|
||||||
struct pppoe_hdr *ph = (struct pppoe_hdr *) skb->nh.raw;
|
struct pppoe_hdr *ph = pppoe_hdr(skb);
|
||||||
int len = ntohs(ph->length);
|
int len = ntohs(ph->length);
|
||||||
skb_pull_rcsum(skb, sizeof(struct pppoe_hdr));
|
skb_pull_rcsum(skb, sizeof(struct pppoe_hdr));
|
||||||
if (pskb_trim_rcsum(skb, len))
|
if (pskb_trim_rcsum(skb, len))
|
||||||
@ -401,7 +401,7 @@ static int pppoe_rcv(struct sk_buff *skb,
|
|||||||
if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
|
if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ph = (struct pppoe_hdr *) skb->nh.raw;
|
ph = pppoe_hdr(skb);
|
||||||
|
|
||||||
po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source, dev->ifindex);
|
po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source, dev->ifindex);
|
||||||
if (po != NULL)
|
if (po != NULL)
|
||||||
@ -433,7 +433,7 @@ static int pppoe_disc_rcv(struct sk_buff *skb,
|
|||||||
if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
|
if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ph = (struct pppoe_hdr *) skb->nh.raw;
|
ph = pppoe_hdr(skb);
|
||||||
if (ph->code != PADT_CODE)
|
if (ph->code != PADT_CODE)
|
||||||
goto abort;
|
goto abort;
|
||||||
|
|
||||||
@ -931,8 +931,6 @@ static int pppoe_recvmsg(struct kiocb *iocb, struct socket *sock,
|
|||||||
struct sock *sk = sock->sk;
|
struct sock *sk = sock->sk;
|
||||||
struct sk_buff *skb = NULL;
|
struct sk_buff *skb = NULL;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int len;
|
|
||||||
struct pppoe_hdr *ph = NULL;
|
|
||||||
|
|
||||||
if (sk->sk_state & PPPOX_BOUND) {
|
if (sk->sk_state & PPPOX_BOUND) {
|
||||||
error = -EIO;
|
error = -EIO;
|
||||||
@ -949,18 +947,14 @@ static int pppoe_recvmsg(struct kiocb *iocb, struct socket *sock,
|
|||||||
m->msg_namelen = 0;
|
m->msg_namelen = 0;
|
||||||
|
|
||||||
if (skb) {
|
if (skb) {
|
||||||
error = 0;
|
struct pppoe_hdr *ph = pppoe_hdr(skb);
|
||||||
ph = (struct pppoe_hdr *) skb->nh.raw;
|
const int len = ntohs(ph->length);
|
||||||
len = ntohs(ph->length);
|
|
||||||
|
|
||||||
error = memcpy_toiovec(m->msg_iov, (unsigned char *) &ph->tag[0], len);
|
error = memcpy_toiovec(m->msg_iov, (unsigned char *) &ph->tag[0], len);
|
||||||
if (error < 0)
|
if (error == 0)
|
||||||
goto do_skb_free;
|
|
||||||
error = len;
|
error = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
do_skb_free:
|
|
||||||
if (skb)
|
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
end:
|
end:
|
||||||
return error;
|
return error;
|
||||||
|
@ -112,6 +112,13 @@ struct pppoe_hdr {
|
|||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
|
#include <linux/skbuff.h>
|
||||||
|
|
||||||
|
static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
|
||||||
|
{
|
||||||
|
return (struct pppoe_hdr *)skb->nh.raw;
|
||||||
|
}
|
||||||
|
|
||||||
struct pppoe_opt {
|
struct pppoe_opt {
|
||||||
struct net_device *dev; /* device associated with socket*/
|
struct net_device *dev; /* device associated with socket*/
|
||||||
int ifindex; /* ifindex of device associated with socket */
|
int ifindex; /* ifindex of device associated with socket */
|
||||||
|
Loading…
Reference in New Issue
Block a user