All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
To: "David S. Miller" <davem@davemloft.net>,
	"YOSHIFUJI Hideaki / 吉藤英明" <yoshfuji@linux-ipv6.org>
Cc: Networking Team <netdev@oss.sgi.com>
Subject: [IPV6] merge raw6_opt with raw6_sock
Date: Mon, 17 Jan 2005 23:30:32 -0200	[thread overview]
Message-ID: <41EC66B8.9080907@conectiva.com.br> (raw)

[-- Attachment #1: Type: text/plain, Size: 179 bytes --]

Hi David,

	This finishes the inet protos part, now to the legacy protocols.

	Available at the usual place:

bk://kernel.bkbits.net/acme/connection_sock-2.6

Regards,

- Arnaldo

[-- Attachment #2: raw6_sock.patch --]
[-- Type: text/plain, Size: 5745 bytes --]

===================================================================


ChangeSet@1.2335, 2005-01-15 19:24:18-02:00, acme@toy.ghostprotocols.net
  [IPV6] merge raw6_sock with raw6_opt
  
  No need for two structs, follow the new inet_sock layout style.
  
  Signed-off-by: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  Signed-off-by: David S. Miller <davem@davemloft.net>


 include/linux/ipv6.h |   23 +++++++++++------------
 net/ipv6/raw.c       |   41 +++++++++++++++++++++--------------------
 2 files changed, 32 insertions(+), 32 deletions(-)


diff -Nru a/include/linux/ipv6.h b/include/linux/ipv6.h
--- a/include/linux/ipv6.h	2005-01-17 23:22:12 -02:00
+++ b/include/linux/ipv6.h	2005-01-17 23:22:12 -02:00
@@ -247,27 +247,26 @@
 	} cork;
 };
 
-struct raw6_opt {
+/* WARNING: don't change the layout of the members in {raw,udp,tcp}6_sock! */
+struct raw6_sock {
+	/* inet_sock has to be the first member of raw6_sock */
+	struct inet_sock	inet;
 	__u32			checksum;	/* perform checksum */
 	__u32			offset;		/* checksum offset  */
-
 	struct icmp6_filter	filter;
-};
-
-/* WARNING: don't change the layout of the members in {raw,udp,tcp}6_sock! */
-struct raw6_sock {
-	struct inet_sock  inet;
-	struct raw6_opt   raw6;
-	struct ipv6_pinfo inet6;
+	/* ipv6_pinfo has to be the last member of raw6_sock, see inet6_sk_generic */
+	struct ipv6_pinfo	inet6;
 };
 
 struct udp6_sock {
 	struct udp_sock	  udp;
+	/* ipv6_pinfo has to be the last member of udp6_sock, see inet6_sk_generic */
 	struct ipv6_pinfo inet6;
 };
 
 struct tcp6_sock {
 	struct tcp_sock	  tcp;
+	/* ipv6_pinfo has to be the last member of tcp6_sock, see inet6_sk_generic */
 	struct ipv6_pinfo inet6;
 };
 
@@ -277,9 +276,9 @@
 	return inet_sk(__sk)->pinet6;
 }
 
-static inline struct raw6_opt * raw6_sk(const struct sock *__sk)
+static inline struct raw6_sock *raw6_sk(const struct sock *sk)
 {
-	return &((struct raw6_sock *)__sk)->raw6;
+	return (struct raw6_sock *)sk;
 }
 
 static inline void inet_sk_copy_descendant(struct sock *sk_to,
@@ -304,7 +303,7 @@
 	return NULL;
 }
 
-static inline struct raw6_opt * raw6_sk(const struct sock *__sk)
+static inline struct raw6_sock *raw6_sk(const struct sock *sk)
 {
 	return NULL;
 }
diff -Nru a/net/ipv6/raw.c b/net/ipv6/raw.c
--- a/net/ipv6/raw.c	2005-01-17 23:22:12 -02:00
+++ b/net/ipv6/raw.c	2005-01-17 23:22:12 -02:00
@@ -115,10 +115,10 @@
 static __inline__ int icmpv6_filter(struct sock *sk, struct sk_buff *skb)
 {
 	struct icmp6hdr *icmph;
-	struct raw6_opt *opt = raw6_sk(sk);
+	struct raw6_sock *rp = raw6_sk(sk);
 
 	if (pskb_may_pull(skb, sizeof(struct icmp6hdr))) {
-		__u32 *data = &opt->filter.data[0];
+		__u32 *data = &rp->filter.data[0];
 		int bit_nr;
 
 		icmph = (struct icmp6hdr *) skb->data;
@@ -315,14 +315,14 @@
 int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
 {
 	struct inet_sock *inet = inet_sk(sk);
-	struct raw6_opt *raw_opt = raw6_sk(sk);
+	struct raw6_sock *rp = raw6_sk(sk);
 
         if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
                 kfree_skb(skb);
                 return NET_RX_DROP;
         }
 
-	if (!raw_opt->checksum)
+	if (!rp->checksum)
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 	if (skb->ip_summed != CHECKSUM_UNNECESSARY) {
@@ -451,21 +451,22 @@
 	goto out_free;
 }
 
-static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct raw6_opt *opt, int len)
+static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
+				     struct raw6_sock *rp, int len)
 {
 	struct sk_buff *skb;
 	int err = 0;
 	u16 *csum;
 	u32 tmp_csum;
 
-	if (!opt->checksum)
+	if (!rp->checksum)
 		goto send;
 
 	if ((skb = skb_peek(&sk->sk_write_queue)) == NULL)
 		goto out;
 
-	if (opt->offset + 1 < len)
-		csum = (u16 *)(skb->h.raw + opt->offset);
+	if (rp->offset + 1 < len)
+		csum = (u16 *)(skb->h.raw + rp->offset);
 	else {
 		err = -EINVAL;
 		goto out;
@@ -609,7 +610,7 @@
 	struct in6_addr *daddr, *final_p = NULL, final;
 	struct inet_sock *inet = inet_sk(sk);
 	struct ipv6_pinfo *np = inet6_sk(sk);
-	struct raw6_opt *raw_opt = raw6_sk(sk);
+	struct raw6_sock *rp = raw6_sk(sk);
 	struct ipv6_txoptions *opt = NULL;
 	struct ip6_flowlabel *flowlabel = NULL;
 	struct dst_entry *dst = NULL;
@@ -771,7 +772,7 @@
 		if (err)
 			ip6_flush_pending_frames(sk);
 		else if (!(msg->msg_flags & MSG_MORE))
-			err = rawv6_push_pending_frames(sk, &fl, raw_opt, len);
+			err = rawv6_push_pending_frames(sk, &fl, rp, len);
 	}
 done:
 	ip6_dst_store(sk, dst,
@@ -838,7 +839,7 @@
 static int rawv6_setsockopt(struct sock *sk, int level, int optname, 
 			    char __user *optval, int optlen)
 {
-	struct raw6_opt *opt = raw6_sk(sk);
+	struct raw6_sock *rp = raw6_sk(sk);
 	int val;
 
 	switch(level) {
@@ -868,10 +869,10 @@
 			if (val > 0 && (val&1))
 				return(-EINVAL);
 			if (val < 0) {
-				opt->checksum = 0;
+				rp->checksum = 0;
 			} else {
-				opt->checksum = 1;
-				opt->offset = val;
+				rp->checksum = 1;
+				rp->offset = val;
 			}
 
 			return 0;
@@ -885,7 +886,7 @@
 static int rawv6_getsockopt(struct sock *sk, int level, int optname, 
 			    char __user *optval, int __user *optlen)
 {
-	struct raw6_opt *opt = raw6_sk(sk);
+	struct raw6_sock *rp = raw6_sk(sk);
 	int val, len;
 
 	switch(level) {
@@ -910,10 +911,10 @@
 
 	switch (optname) {
 	case IPV6_CHECKSUM:
-		if (opt->checksum == 0)
+		if (rp->checksum == 0)
 			val = -1;
 		else
-			val = opt->offset;
+			val = rp->offset;
 		break;
 
 	default:
@@ -966,9 +967,9 @@
 static int rawv6_init_sk(struct sock *sk)
 {
 	if (inet_sk(sk)->num == IPPROTO_ICMPV6) {
-		struct raw6_opt *opt = raw6_sk(sk);
-		opt->checksum = 1;
-		opt->offset = 2;
+		struct raw6_sock *rp = raw6_sk(sk);
+		rp->checksum = 1;
+		rp->offset   = 2;
 	}
 	return(0);
 }


             reply	other threads:[~2005-01-18  1:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-18  1:30 Arnaldo Carvalho de Melo [this message]
2005-01-18  3:20 ` [IPV6] merge raw6_opt with raw6_sock YOSHIFUJI Hideaki / 吉藤英明
2005-01-18 20:58 ` David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41EC66B8.9080907@conectiva.com.br \
    --to=acme@conectiva.com.br \
    --cc=davem@davemloft.net \
    --cc=netdev@oss.sgi.com \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.