Skip to content

Commit

Permalink
[NET]: Turn nfmark into generic mark
Browse files Browse the repository at this point in the history
nfmark is being used in various subsystems and has become
the defacto mark field for all kinds of packets. Therefore
it makes sense to rename it to `mark' and remove the
dependency on CONFIG_NETFILTER.

Signed-off-by: Thomas Graf <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
tgraf authored and David S. Miller committed Dec 3, 2006
1 parent 0afc46c commit 82e91ff
Show file tree
Hide file tree
Showing 28 changed files with 59 additions and 68 deletions.
4 changes: 2 additions & 2 deletions include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ enum {
* @tail: Tail pointer
* @end: End pointer
* @destructor: Destruct function
* @nfmark: Can be used for communication between hooks
* @mark: Generic packet mark
* @nfct: Associated connection, if any
* @ipvs_property: skbuff is owned by ipvs
* @nfctinfo: Relationship of this skb to the connection
Expand Down Expand Up @@ -295,7 +295,6 @@ struct sk_buff {
#ifdef CONFIG_BRIDGE_NETFILTER
struct nf_bridge_info *nf_bridge;
#endif
__u32 nfmark;
#endif /* CONFIG_NETFILTER */
#ifdef CONFIG_NET_SCHED
__u16 tc_index; /* traffic control index */
Expand All @@ -310,6 +309,7 @@ struct sk_buff {
__u32 secmark;
#endif

__u32 mark;

/* These elements must be at the end, see alloc_skb() for details. */
unsigned int truesize;
Expand Down
8 changes: 4 additions & 4 deletions net/bridge/netfilter/ebt_mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ static int ebt_target_mark(struct sk_buff **pskb, unsigned int hooknr,
int action = info->target & -16;

if (action == MARK_SET_VALUE)
(*pskb)->nfmark = info->mark;
(*pskb)->mark = info->mark;
else if (action == MARK_OR_VALUE)
(*pskb)->nfmark |= info->mark;
(*pskb)->mark |= info->mark;
else if (action == MARK_AND_VALUE)
(*pskb)->nfmark &= info->mark;
(*pskb)->mark &= info->mark;
else
(*pskb)->nfmark ^= info->mark;
(*pskb)->mark ^= info->mark;

return info->target | -16;
}
Expand Down
4 changes: 2 additions & 2 deletions net/bridge/netfilter/ebt_mark_m.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ static int ebt_filter_mark(const struct sk_buff *skb,
struct ebt_mark_m_info *info = (struct ebt_mark_m_info *) data;

if (info->bitmask & EBT_MARK_OR)
return !(!!(skb->nfmark & info->mask) ^ info->invert);
return !(((skb->nfmark & info->mask) == info->mark) ^ info->invert);
return !(!!(skb->mark & info->mask) ^ info->invert);
return !(((skb->mark & info->mask) == info->mark) ^ info->invert);
}

static int ebt_mark_check(const char *tablename, unsigned int hookmask,
Expand Down
2 changes: 1 addition & 1 deletion net/bridge/netfilter/ebt_ulog.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static void ebt_ulog_packet(unsigned int hooknr, const struct sk_buff *skb,
if (ub->qlen == 1)
skb_set_timestamp(ub->skb, &pm->stamp);
pm->data_len = copy_len;
pm->mark = skb->nfmark;
pm->mark = skb->mark;
pm->hook = hooknr;
if (uloginfo->prefix != NULL)
strcpy(pm->prefix, uloginfo->prefix);
Expand Down
4 changes: 2 additions & 2 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,8 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask)
#endif
C(protocol);
n->destructor = NULL;
C(mark);
#ifdef CONFIG_NETFILTER
C(nfmark);
C(nfct);
nf_conntrack_get(skb->nfct);
C(nfctinfo);
Expand Down Expand Up @@ -534,8 +534,8 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
new->pkt_type = old->pkt_type;
new->tstamp = old->tstamp;
new->destructor = NULL;
new->mark = old->mark;
#ifdef CONFIG_NETFILTER
new->nfmark = old->nfmark;
new->nfct = old->nfct;
nf_conntrack_get(old->nfct);
new->nfctinfo = old->nfctinfo;
Expand Down
4 changes: 2 additions & 2 deletions net/decnet/dn_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
.saddr = cb->src,
.scope = RT_SCOPE_UNIVERSE,
#ifdef CONFIG_DECNET_ROUTE_FWMARK
.fwmark = skb->nfmark
.fwmark = skb->mark
#endif
} },
.iif = skb->dev->ifindex };
Expand Down Expand Up @@ -1458,7 +1458,7 @@ int dn_route_input(struct sk_buff *skb)
(rt->fl.fld_dst == cb->dst) &&
(rt->fl.oif == 0) &&
#ifdef CONFIG_DECNET_ROUTE_FWMARK
(rt->fl.fld_fwmark == skb->nfmark) &&
(rt->fl.fld_fwmark == skb->mark) &&
#endif
(rt->fl.iif == cb->iif)) {
rt->u.dst.lastuse = jiffies;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/ip_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
dst_release(to->dst);
to->dst = dst_clone(from->dst);
to->dev = from->dev;
to->mark = from->mark;

/* Copy the flags to each fragment. */
IPCB(to)->flags = IPCB(from)->flags;
Expand All @@ -394,7 +395,6 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
to->tc_index = from->tc_index;
#endif
#ifdef CONFIG_NETFILTER
to->nfmark = from->nfmark;
/* Connection association is same as pre-frag packet */
nf_conntrack_put(to->nfct);
to->nfct = from->nfct;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/ipvs/ip_vs_proto_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ tcp_conn_schedule(struct sk_buff *skb,
}

if (th->syn &&
(svc = ip_vs_service_get(skb->nfmark, skb->nh.iph->protocol,
(svc = ip_vs_service_get(skb->mark, skb->nh.iph->protocol,
skb->nh.iph->daddr, th->dest))) {
if (ip_vs_todrop()) {
/*
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/ipvs/ip_vs_proto_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ udp_conn_schedule(struct sk_buff *skb, struct ip_vs_protocol *pp,
return 0;
}

if ((svc = ip_vs_service_get(skb->nfmark, skb->nh.iph->protocol,
if ((svc = ip_vs_service_get(skb->mark, skb->nh.iph->protocol,
skb->nh.iph->daddr, uh->dest))) {
if (ip_vs_todrop()) {
/*
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/netfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int ip_route_me_harder(struct sk_buff **pskb, unsigned addr_type)
fl.nl_u.ip4_u.tos = RT_TOS(iph->tos);
fl.oif = (*pskb)->sk ? (*pskb)->sk->sk_bound_dev_if : 0;
#ifdef CONFIG_IP_ROUTE_FWMARK
fl.nl_u.ip4_u.fwmark = (*pskb)->nfmark;
fl.nl_u.ip4_u.fwmark = (*pskb)->mark;
#endif
if (ip_route_output_key(&rt, &fl) != 0)
return -1;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/ip_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
pmsg->data_len = data_len;
pmsg->timestamp_sec = entry->skb->tstamp.off_sec;
pmsg->timestamp_usec = entry->skb->tstamp.off_usec;
pmsg->mark = entry->skb->nfmark;
pmsg->mark = entry->skb->mark;
pmsg->hook = entry->info->hook;
pmsg->hw_protocol = entry->skb->protocol;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/ipt_REJECT.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static void send_reset(struct sk_buff *oldskb, int hook)

/* This packet will not be the same as the other: clear nf fields */
nf_reset(nskb);
nskb->nfmark = 0;
nskb->mark = 0;
skb_init_secmark(nskb);

tcph = (struct tcphdr *)((u_int32_t*)nskb->nh.iph + nskb->nh.iph->ihl);
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/ipt_ULOG.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static void ipt_ulog_packet(unsigned int hooknum,
pm->data_len = copy_len;
pm->timestamp_sec = skb->tstamp.off_sec;
pm->timestamp_usec = skb->tstamp.off_usec;
pm->mark = skb->nfmark;
pm->mark = skb->mark;
pm->hook = hooknum;
if (prefix != NULL)
strncpy(pm->prefix, prefix, sizeof(pm->prefix));
Expand Down
6 changes: 3 additions & 3 deletions net/ipv4/netfilter/iptable_mangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ ipt_local_hook(unsigned int hook,
unsigned int ret;
u_int8_t tos;
__be32 saddr, daddr;
unsigned long nfmark;
u_int32_t mark;

/* root is playing with raw sockets. */
if ((*pskb)->len < sizeof(struct iphdr)
Expand All @@ -143,7 +143,7 @@ ipt_local_hook(unsigned int hook,
}

/* Save things which could affect route */
nfmark = (*pskb)->nfmark;
mark = (*pskb)->mark;
saddr = (*pskb)->nh.iph->saddr;
daddr = (*pskb)->nh.iph->daddr;
tos = (*pskb)->nh.iph->tos;
Expand All @@ -154,7 +154,7 @@ ipt_local_hook(unsigned int hook,
&& ((*pskb)->nh.iph->saddr != saddr
|| (*pskb)->nh.iph->daddr != daddr
#ifdef CONFIG_IP_ROUTE_FWMARK
|| (*pskb)->nfmark != nfmark
|| (*pskb)->mark != mark
#endif
|| (*pskb)->nh.iph->tos != tos))
if (ip_route_me_harder(pskb, RTN_UNSPEC))
Expand Down
10 changes: 5 additions & 5 deletions net/ipv4/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
rth->rt_dst = daddr;
rth->fl.fl4_tos = tos;
#ifdef CONFIG_IP_ROUTE_FWMARK
rth->fl.fl4_fwmark= skb->nfmark;
rth->fl.fl4_fwmark= skb->mark;
#endif
rth->fl.fl4_src = saddr;
rth->rt_src = saddr;
Expand Down Expand Up @@ -1790,7 +1790,7 @@ static inline int __mkroute_input(struct sk_buff *skb,
rth->rt_dst = daddr;
rth->fl.fl4_tos = tos;
#ifdef CONFIG_IP_ROUTE_FWMARK
rth->fl.fl4_fwmark= skb->nfmark;
rth->fl.fl4_fwmark= skb->mark;
#endif
rth->fl.fl4_src = saddr;
rth->rt_src = saddr;
Expand Down Expand Up @@ -1921,7 +1921,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
.tos = tos,
.scope = RT_SCOPE_UNIVERSE,
#ifdef CONFIG_IP_ROUTE_FWMARK
.fwmark = skb->nfmark
.fwmark = skb->mark
#endif
} },
.iif = dev->ifindex };
Expand Down Expand Up @@ -2035,7 +2035,7 @@ out: return err;
rth->rt_dst = daddr;
rth->fl.fl4_tos = tos;
#ifdef CONFIG_IP_ROUTE_FWMARK
rth->fl.fl4_fwmark= skb->nfmark;
rth->fl.fl4_fwmark= skb->mark;
#endif
rth->fl.fl4_src = saddr;
rth->rt_src = saddr;
Expand Down Expand Up @@ -2114,7 +2114,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
rth->fl.iif == iif &&
rth->fl.oif == 0 &&
#ifdef CONFIG_IP_ROUTE_FWMARK
rth->fl.fl4_fwmark == skb->nfmark &&
rth->fl.fl4_fwmark == skb->mark &&
#endif
rth->fl.fl4_tos == tos) {
rth->u.dst.lastuse = jiffies;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/ip6_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,12 +499,12 @@ static void ip6_copy_metadata(struct sk_buff *to, struct sk_buff *from)
dst_release(to->dst);
to->dst = dst_clone(from->dst);
to->dev = from->dev;
to->mark = from->mark;

#ifdef CONFIG_NET_SCHED
to->tc_index = from->tc_index;
#endif
#ifdef CONFIG_NETFILTER
to->nfmark = from->nfmark;
/* Connection association is same as pre-frag packet */
nf_conntrack_put(to->nfct);
to->nfct = from->nfct;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/ip6_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
pmsg->data_len = data_len;
pmsg->timestamp_sec = entry->skb->tstamp.off_sec;
pmsg->timestamp_usec = entry->skb->tstamp.off_usec;
pmsg->mark = entry->skb->nfmark;
pmsg->mark = entry->skb->mark;
pmsg->hook = entry->info->hook;
pmsg->hw_protocol = entry->skb->protocol;

Expand Down
9 changes: 4 additions & 5 deletions net/ipv6/netfilter/ip6table_mangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,10 @@ ip6t_local_hook(unsigned int hook,
int (*okfn)(struct sk_buff *))
{

unsigned long nfmark;
unsigned int ret;
struct in6_addr saddr, daddr;
u_int8_t hop_limit;
u_int32_t flowlabel;
u_int32_t flowlabel, mark;

#if 0
/* root is playing with raw sockets. */
Expand All @@ -165,10 +164,10 @@ ip6t_local_hook(unsigned int hook,
}
#endif

/* save source/dest address, nfmark, hoplimit, flowlabel, priority, */
/* save source/dest address, mark, hoplimit, flowlabel, priority, */
memcpy(&saddr, &(*pskb)->nh.ipv6h->saddr, sizeof(saddr));
memcpy(&daddr, &(*pskb)->nh.ipv6h->daddr, sizeof(daddr));
nfmark = (*pskb)->nfmark;
mark = (*pskb)->mark;
hop_limit = (*pskb)->nh.ipv6h->hop_limit;

/* flowlabel and prio (includes version, which shouldn't change either */
Expand All @@ -179,7 +178,7 @@ ip6t_local_hook(unsigned int hook,
if (ret != NF_DROP && ret != NF_STOLEN
&& (memcmp(&(*pskb)->nh.ipv6h->saddr, &saddr, sizeof(saddr))
|| memcmp(&(*pskb)->nh.ipv6h->daddr, &daddr, sizeof(daddr))
|| (*pskb)->nfmark != nfmark
|| (*pskb)->mark != mark
|| (*pskb)->nh.ipv6h->hop_limit != hop_limit))
return ip6_route_me_harder(*pskb) == 0 ? ret : NF_DROP;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ void ip6_route_input(struct sk_buff *skb)
.daddr = iph->daddr,
.saddr = iph->saddr,
#ifdef CONFIG_IPV6_ROUTE_FWMARK
.fwmark = skb->nfmark,
.fwmark = skb->mark,
#endif
.flowlabel = (* (__be32 *) iph)&IPV6_FLOWINFO_MASK,
},
Expand Down
4 changes: 2 additions & 2 deletions net/netfilter/nfnetlink_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ __build_packet_message(struct nfulnl_instance *inst,
#endif
}

if (skb->nfmark) {
tmp_uint = htonl(skb->nfmark);
if (skb->mark) {
tmp_uint = htonl(skb->mark);
NFA_PUT(inst->skb, NFULA_MARK, sizeof(tmp_uint), &tmp_uint);
}

Expand Down
8 changes: 4 additions & 4 deletions net/netfilter/nfnetlink_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
#endif
}

if (entskb->nfmark) {
tmp_uint = htonl(entskb->nfmark);
if (entskb->mark) {
tmp_uint = htonl(entskb->mark);
NFA_PUT(skb, NFQA_MARK, sizeof(u_int32_t), &tmp_uint);
}

Expand Down Expand Up @@ -834,8 +834,8 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
}

if (nfqa[NFQA_MARK-1])
entry->skb->nfmark = ntohl(*(__be32 *)
NFA_DATA(nfqa[NFQA_MARK-1]));
entry->skb->mark = ntohl(*(__be32 *)
NFA_DATA(nfqa[NFQA_MARK-1]));

issue_verdict(entry, verdict);
instance_put(queue);
Expand Down
10 changes: 5 additions & 5 deletions net/netfilter/xt_CONNMARK.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ target(struct sk_buff **pskb,
{
const struct xt_connmark_target_info *markinfo = targinfo;
u_int32_t diff;
u_int32_t nfmark;
u_int32_t mark;
u_int32_t newmark;
u_int32_t ctinfo;
u_int32_t *ctmark = nf_ct_get_mark(*pskb, &ctinfo);
Expand All @@ -62,7 +62,7 @@ target(struct sk_buff **pskb,
break;
case XT_CONNMARK_SAVE:
newmark = (*ctmark & ~markinfo->mask) |
((*pskb)->nfmark & markinfo->mask);
((*pskb)->mark & markinfo->mask);
if (*ctmark != newmark) {
*ctmark = newmark;
#if defined(CONFIG_IP_NF_CONNTRACK) || defined(CONFIG_IP_NF_CONNTRACK_MODULE)
Expand All @@ -73,10 +73,10 @@ target(struct sk_buff **pskb,
}
break;
case XT_CONNMARK_RESTORE:
nfmark = (*pskb)->nfmark;
diff = (*ctmark ^ nfmark) & markinfo->mask;
mark = (*pskb)->mark;
diff = (*ctmark ^ mark) & markinfo->mask;
if (diff != 0)
(*pskb)->nfmark = nfmark ^ diff;
(*pskb)->mark = mark ^ diff;
break;
}
}
Expand Down
Loading

0 comments on commit 82e91ff

Please sign in to comment.