Skip to content

Commit

Permalink
check for pktinfo needcopy/needfree inconsistency.
Browse files Browse the repository at this point in the history
maybe we should just remove the 2nd arg of ip6_clearpktopts().

(inconsistency do seem to happen - try "ping6 ::1 ::1 ::1" on freebsd2)
  • Loading branch information
itojun committed Aug 20, 2000
1 parent e814512 commit e1b4463
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 14 additions & 1 deletion kame/sys/netinet6/ip6_output.c
@@ -1,4 +1,4 @@
/* $KAME: ip6_output.c,v 1.122 2000/08/19 02:12:02 jinmei Exp $ */
/* $KAME: ip6_output.c,v 1.123 2000/08/20 04:44:19 itojun Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -2612,6 +2612,17 @@ ip6_clearpktopts(pktopt, needfree, optname)
if (pktopt == NULL)
return;

#ifdef DIAGNOSTIC
if ((needfree && !pktopt->needfree) ||
(!needfree && pktopt->needfree)) {
#if 0
panic("needfree inconsistent");
#else
printf("needfree inconsistent: %p %d %d\n", pktopt, needfree,
pktopt->needfree);
#endif
}
#endif
if (optname == -1 || optname == IPV6_PKTINFO) {
if (needfree && pktopt->ip6po_pktinfo)
free(pktopt->ip6po_pktinfo, M_IP6OPT);
Expand Down Expand Up @@ -2675,6 +2686,7 @@ ip6_copypktopts(src, canwait)
if (dst == NULL && canwait == M_NOWAIT)
goto bad;
bzero(dst, sizeof(*dst));
dst->needfree = 1;

dst->ip6po_hlim = src->ip6po_hlim;
dst->ip6po_flags = src->ip6po_flags;
Expand Down Expand Up @@ -3124,6 +3136,7 @@ ip6_setpktoptions(control, opt, priv, needcopy)

bzero(opt, sizeof(*opt));
opt->ip6po_hlim = -1; /* -1 means to use default hop limit */
opt->needfree = needcopy;

/*
* XXX: Currently, we assume all the optional information is stored
Expand Down
4 changes: 3 additions & 1 deletion kame/sys/netinet6/ip6_var.h
@@ -1,4 +1,4 @@
/* $KAME: ip6_var.h,v 1.40 2000/08/17 01:08:40 itojun Exp $ */
/* $KAME: ip6_var.h,v 1.41 2000/08/20 04:44:19 itojun Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -152,6 +152,8 @@ struct ip6_pktopts {
int ip6po_flags;
#define IP6PO_REACHCONF 0x01 /* upper-layer reachability confirmation */
#define IP6PO_MINMTU 0x02 /* use minimum MTU (IPV6_USE_MIN_MTU) */

int needfree; /* members dynamically allocated */
};

/*
Expand Down

0 comments on commit e1b4463

Please sign in to comment.