1 /* mplsbr.c: ethernet over MPLS protocol driver.
3 * Copyright (C) 2005 James R. Leu (jleu@mindspring.com)
6 #include <linux/module.h>
7 #include <linux/socket.h>
8 #include <linux/skbuff.h>
9 #include <linux/init.h>
10 #include <net/neighbour.h>
14 MODULE_LICENSE("GPL");
16 static void dumb_neigh_solicit(struct neighbour
*neigh
,struct sk_buff
*skb
)
20 static void dumb_neigh_error(struct neighbour
*neigh
,struct sk_buff
*skb
)
25 static int dumb_neigh_dev_xmit(struct sk_buff
*skb
)
27 skb
->dev
= skb_dst(skb
)->dev
;
28 skb
->ip_summed
= CHECKSUM_NONE
;
34 static struct neigh_ops dumb_neigh_ops
= {
36 .solicit
= dumb_neigh_solicit
,
37 .error_report
= dumb_neigh_error
,
38 .output
= dumb_neigh_dev_xmit
,
39 .connected_output
= dumb_neigh_dev_xmit
,
40 .hh_output
= dumb_neigh_dev_xmit
,
41 .queue_xmit
= dumb_neigh_dev_xmit
,
44 static u32
dumb_neigh_hash(const void *pkey
, const struct net_device
*dev
)
49 static int dumb_neigh_constructor(struct neighbour
*neigh
)
51 neigh
->ops
= &dumb_neigh_ops
;
52 neigh
->output
= neigh
->ops
->output
;
56 static struct neigh_table dumb_tbl
= {
58 .entry_size
= sizeof(struct neighbour
),
60 .hash
= dumb_neigh_hash
,
61 .constructor
= dumb_neigh_constructor
,
64 /* parameters are copied from ARP ... */
67 .base_reachable_time
= 30 * HZ
,
68 .retrans_time
= 1 * HZ
,
69 .gc_staletime
= 60 * HZ
,
70 .reachable_time
= 30 * HZ
,
71 .delay_probe_time
= 5 * HZ
,
75 .anycast_delay
= 1 * HZ
,
76 .proxy_delay
= (8 * HZ
) / 10,
80 .gc_interval
= 30 * HZ
,
86 static void mplsbr_cache_flush(struct net
*net
)
90 static void mplsbr_set_ttl(struct sk_buff
*skb
, int ttl
)
94 static int mplsbr_get_ttl(struct sk_buff
*skb
)
99 static void mplsbr_change_dsfield(struct sk_buff
*skb
, int ds
)
104 static int mplsbr_get_dsfield(struct sk_buff
*skb
)
110 static int mplsbr_ttl_expired(struct sk_buff
**skb
)
115 static int mplsbr_mtu_exceeded(struct sk_buff
**skb
, int mtu
)
117 return MPLS_RESULT_DROP
;
120 static int mplsbr_local_deliver(struct sk_buff
*skb
)
125 static int mplsbr_nexthop_resolve(struct neighbour
**np
,
126 struct sockaddr
*sock_addr
, struct net_device
*dev
)
129 u32 index
= dev
->ifindex
;
131 n
= __neigh_lookup_errno(&dumb_tbl
, &index
, dev
);
139 static struct mpls_prot_driver mplsbr_driver
= {
142 .ethertype
= __constant_htons(ETH_P_ALL
),
143 .cache_flush
= mplsbr_cache_flush
,
144 .set_ttl
= mplsbr_set_ttl
,
145 .get_ttl
= mplsbr_get_ttl
,
146 .change_dsfield
= mplsbr_change_dsfield
,
147 .get_dsfield
= mplsbr_get_dsfield
,
148 .ttl_expired
= mplsbr_ttl_expired
,
149 .mtu_exceeded
= mplsbr_mtu_exceeded
,
150 .local_deliver
= mplsbr_local_deliver
,
151 .nexthop_resolve
= mplsbr_nexthop_resolve
,
152 .owner
= THIS_MODULE
,
155 static int __init
mplsbr_init(void)
157 printk("MPLS: Ethernet over MPLS support\n");
158 neigh_table_init(&dumb_tbl
);
159 return mpls_proto_add(&mplsbr_driver
);
162 static void __exit
mplsbr_fini(void)
164 mpls_proto_remove(&mplsbr_driver
);
167 module_init(mplsbr_init
);
168 module_exit(mplsbr_fini
);